Skip to content

3.6.0

Choose a tag to compare

@binaryk binaryk released this 09 Jun 20:53
· 172 commits to 3.x since this release
0a892da

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'