1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Pratiksh\Adminetic\Http\Livewire\Admin\Role; |
4
|
|
|
|
5
|
|
|
use Livewire\Component; |
6
|
|
|
use Pratiksh\Adminetic\Models\Admin\Permission; |
7
|
|
|
use Pratiksh\Adminetic\Models\Admin\Role; |
8
|
|
|
|
9
|
|
|
class Bread extends Component |
10
|
|
|
{ |
11
|
|
|
public $permission; |
12
|
|
|
public $browse = true; |
13
|
|
|
public $read = true; |
14
|
|
|
public $edit = true; |
15
|
|
|
public $add = true; |
16
|
|
|
public $delete = true; |
17
|
|
|
|
18
|
|
|
public function mount(Permission $permission) |
19
|
|
|
{ |
20
|
|
|
$this->permission = $permission; |
21
|
|
|
$this->browse = $permission->browse; |
22
|
|
|
$this->read = $permission->read; |
23
|
|
|
$this->edit = $permission->edit; |
24
|
|
|
$this->add = $permission->add; |
25
|
|
|
$this->delete = $permission->delete; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function updatedBrowse() |
29
|
|
|
{ |
30
|
|
|
$this->permission->update([ |
31
|
|
|
'browse' => $this->browse |
32
|
|
|
]); |
33
|
|
|
$this->emit('bread_updated', $this->permission->model . " model browse flag updated"); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function updatedRead() |
37
|
|
|
{ |
38
|
|
|
$this->permission->update([ |
39
|
|
|
'read' => $this->read |
40
|
|
|
]); |
41
|
|
|
$this->emit('bread_updated', $this->permission->model . " model read flag updated"); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function updatedEdit() |
45
|
|
|
{ |
46
|
|
|
$this->permission->update([ |
47
|
|
|
'edit' => $this->edit |
48
|
|
|
]); |
49
|
|
|
$this->emit('bread_updated', $this->permission->model . " model edit flag updated"); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function updatedAdd() |
53
|
|
|
{ |
54
|
|
|
$this->permission->update([ |
55
|
|
|
'add' => $this->add |
56
|
|
|
]); |
57
|
|
|
$this->emit('bread_updated', $this->permission->model . " model add flag updated"); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function updatedDelete() |
61
|
|
|
{ |
62
|
|
|
$this->permission->update([ |
63
|
|
|
'delete' => $this->delete |
64
|
|
|
]); |
65
|
|
|
$this->emit('bread_updated', $this->permission->model . " model delete flag updated"); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function delete() |
69
|
|
|
{ |
70
|
|
|
$this->permission->delete(); |
71
|
|
|
$this->permission = null; |
72
|
|
|
$this->emit('permission_deleted'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function render() |
76
|
|
|
{ |
77
|
|
|
return view('adminetic::livewire.admin.role.bread'); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|