Skip to content
Discussion options

You must be logged in to vote

To answer your question about passing the user_id to the pivot table while maintaining a select2 list of Pages, we can use the relationship field type with some specific configurations. Here's how you can achieve this:

  1. First, modify your relationship definition to include the user_id in the withPivot() method:
public function permissionPages()
{
    return $this->belongsToMany(
        Page::class,
        'user_permission_contents',
        'content_id',
        'id',
    )->withPivot('user_id');
}
  1. Then, in your CRUD controller, define the field like this:
CRUD::field([
    'name' => 'permissionPages',
    'type' => 'relationship',
    'tab' => $permissions_tab,
    'subfields' => [
…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tabacitu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants