Passed
Push — main ( 5e9128...7e664e )
by PRATIK
03:55
created

Bread::updatedEdit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
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