T
Size: a a a
T
MK
MK
A
lv
AP
class RepositoryServiceProvider extends ServiceProvider
{
// ...
$this->app->bind(ModelRepositoryInterface::class, function() {
return new PermissionRepository(new Permission);
});
// ...
}
Target [Illuminate\Database\Eloquent\Model] is not instantiable while building [App\Http\Controllers\Api\V1\User\RoleController, App\Repositories\Model\RoleRepository]dd(new Role):Call to a member function connection() on null. MW
MW
AP
dd(new Role) в метод boot то экземпляр создаётся. И создаётся dd(new PermissionRepository(new Permission)), но не биндится.AP
Spatie\Permission\Models\RoleА
AP
AP
class RoleController extends Controller
{
/**
* Репозиторий
*
* @var RoleRepository
*/
private RoleRepository $repository;
public function __construct(RoleRepository $repository)
{
$this->repository = $repository;
}
/**
* Получить всех ролей
*
* @return JsonResponse
*/
public function all(): JsonResponse
{
$roles = $this->repository->all();
return $this->prepareResponse(['roles' => $roles]);
}
}
AP
А
А