Vishal Tarkar
Vishal Tarkar

Reputation: 826

How to Update & Delete Roles in Sentinel Laravel 5.4?

I have done with user role create. below is its code.

$role = Sentinel::getRoleRepository()->createModel()->create([
    'name' => request('name'),
    'slug' => request('slug')           
]);

But I am not sure if below update & delete code will work.

Delete Code

$role = Sentinel::findRoleById($this->data['id']));

Edit Code ( I know its wrong, because it making no sense :) )

$role = Sentinel::findRoleById(request('role_id'));
$role = Sentinel::getRoleRepository()->createModel()->update([
    'name' => request('name'),
    'slug' => request('slug')
]);

Please help me out.

Upvotes: 0

Views: 1095

Answers (1)

A. Modji
A. Modji

Reputation: 11

Have you tried the following code. That should normally work.

$role = Sentinel::findRoleById($id);
$role->delete();

Upvotes: 1

Related Questions