Single   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 26
c 1
b 0
f 0
dl 0
loc 61
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 13 1
A mount() 0 3 1
A active() 0 8 1
A delete() 0 10 1
A inactive() 0 8 1
A render() 0 4 1
1
<?php
2
3
namespace EasyPanel\Http\Livewire\CRUD;
4
5
use Livewire\Component;
6
use EasyPanel\Models\CRUD;
7
use Illuminate\Support\Facades\Artisan;
8
9
class Single extends Component
10
{
11
12
    public $crud;
13
14
    public function mount(CRUD $crud)
15
    {
16
        $this->crud = $crud;
17
    }
18
19
    public function delete()
20
    {
21
        Artisan::call('panel:delete', [
22
            'name' => $this->crud->name,
23
            '--force' => true,
24
        ]);
25
26
        $this->crud->delete();
27
        $this->dispatchBrowserEvent('show-message', ['type' => 'error', 'message' => __('DeletedMessage', ['name' => __('CRUD') ] )]);
28
        $this->emit('crudUpdated');
29
    }
30
31
    public function build()
32
    {
33
        Artisan::call('panel:crud', [
34
            'name' => $this->crud->name,
35
            '--force' => true,
36
        ]);
37
38
        $this->crud->update([
39
            'built' => true
40
        ]);
41
42
        $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD Created successfully') ] );
43
        $this->emit('crudUpdated');
44
    }
45
46
    public function inactive()
47
    {
48
        $this->crud->update([
49
            'active' => false
50
        ]);
51
52
        $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD was inactivated') ] );
53
        $this->emit('crudUpdated');
54
    }
55
56
    public function active()
57
    {
58
        $this->crud->update([
59
            'active' => true
60
        ]);
61
62
        $this->dispatchBrowserEvent('show-message', ['type' => 'success', 'message' => __('CRUD was activated') ] );
63
        $this->emit('crudUpdated');
64
    }
65
66
    public function render()
67
    {
68
        return view('admin::livewire.crud.single')
69
            ->layout('admin::layouts.app');
70
    }
71
}
72