I need to display only those records in the model that are attached to some groups. ("belongsToMany" Relations). (backend page of plugin list of Movies model) I want to get the groups of the current user and create a query.
What I mean:
I use Relations field to to attach records to groups.
i.e:
- I have table "elisseii_myplugin_movies".
- In the "Movies" model, I created a relation field with the name "groups".
- and created the table "elisseii_myplugin_movies_groups".
Used $belongsToMany in the "Movies" model.
public $belongsToMany =[ 'groups' =>[ 'Elisseiidev\MyPlugin\Models\Groups', 'table' => 'elisseii_myplugin_movies_groups', 'order' => 'name' ] ];
The "Groups" model in the plug-in uses the standard table "backend_user_groups".
Now records have information about the groups attached to them. You can see the video tutorial, which says about it)
I need that users can not edit records that do not belong to their group. It is necessary that the code be dynamic.
I need a detailed answer, since I'm learning)) Thank you in advance for your time.