3.6.0
Added
Ability to setup your own attachers. For example if you want to attach users to a role, and you don't want to use the default attach method. In this case you can override the attach method like this:
// RoleRepository.php
public function attachUsers(RestifyRequest $request, Repository $repository, Model $model)
{
ModelHasRole::create([
'role_id' => $model->id,
'model_type' => User::class,
'model_id' => $request->get('users'),
]);
return $this->response()->created();
}
The URL used for attach will remain the same as for a normal attach:
'restify-api/roles/' . $role->id . '/attach/users'