Lists::buildAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 16
rs 10
1
<?php
2
3
namespace EasyPanel\Http\Livewire\CRUD;
4
5
use Livewire\Component;
6
use Livewire\WithPagination;
7
use EasyPanel\Models\CRUD;
8
use Illuminate\Support\Facades\Artisan;
9
10
class Lists extends Component
11
{
12
    use WithPagination;
13
14
    protected $paginationTheme = 'bootstrap';
15
16
    protected $listeners = ['crudUpdated'];
17
18
    public function crudUpdated()
19
    {
20
        // There is nothing to do, just update It.
21
    }
22
23
    public function buildAll()
24
    {
25
        Artisan::call('panel:crud', [
26
            '--force' => true
27
        ]);
28
29
        CRUD::query()->where('active', true)->update([
30
            'built' => true
31
        ]);
32
33
        $this->dispatchBrowserEvent('show-message', [
34
            'type' => 'success',
35
            'message' => __('CRUD Created successfully')
36
        ]);
37
38
        $this->redirect(route(getRouteName().'.crud.lists'));
39
    }
40
41
    public function render()
42
    {
43
        $cruds = CRUD::query()
44
            ->paginate(20);
45
46
        return view('admin::livewire.crud.lists', compact('cruds'))
47
            ->layout('admin::layouts.app', ['title' => __('ListTitle', ['name' => __('CRUD')])]);
48
    }
49
}
50