|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Xetaravel\Livewire\Admin\Permission; |
|
6
|
|
|
|
|
7
|
|
|
use Illuminate\Contracts\View\Factory; |
|
8
|
|
|
use Illuminate\Contracts\View\View; |
|
9
|
|
|
use Illuminate\Foundation\Application; |
|
10
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
|
11
|
|
|
use Livewire\Attributes\On; |
|
12
|
|
|
use Livewire\Component; |
|
13
|
|
|
use Masmerise\Toaster\Toastable; |
|
14
|
|
|
use Spatie\Permission\Models\Permission as PermissionModel; |
|
15
|
|
|
use Xetaravel\Livewire\Forms\PermissionForm; |
|
16
|
|
|
|
|
17
|
|
|
class CreatePermission extends Component |
|
18
|
|
|
{ |
|
19
|
|
|
use AuthorizesRequests; |
|
20
|
|
|
use Toastable; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* The form used to create/update a model. |
|
24
|
|
|
* |
|
25
|
|
|
* @var PermissionForm |
|
26
|
|
|
*/ |
|
27
|
|
|
public PermissionForm $form; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Used to show the create modal. |
|
31
|
|
|
* |
|
32
|
|
|
* @var bool |
|
33
|
|
|
*/ |
|
34
|
|
|
public bool $showModal = false; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Create a blank model and assign it to the model. (Used in create modal) |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
|
|
#[On('create-permission')] |
|
42
|
|
|
public function createPermission(): void |
|
43
|
|
|
{ |
|
44
|
|
|
$this->authorize('create', PermissionModel::class); |
|
45
|
|
|
|
|
46
|
|
|
$this->form->reset(); |
|
47
|
|
|
|
|
48
|
|
|
$this->showModal = true; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Validate and save the model. |
|
53
|
|
|
* |
|
54
|
|
|
* @return void |
|
55
|
|
|
*/ |
|
56
|
|
|
public function create(): void |
|
57
|
|
|
{ |
|
58
|
|
|
$this->authorize('create', PermissionModel::class); |
|
59
|
|
|
|
|
60
|
|
|
$this->validate(); |
|
61
|
|
|
|
|
62
|
|
|
$this->form->create(); |
|
63
|
|
|
|
|
64
|
|
|
$this->showModal = false; |
|
65
|
|
|
|
|
66
|
|
|
redirect() |
|
67
|
|
|
->route('admin.permission.index') |
|
|
|
|
|
|
68
|
|
|
->success('Your permission has been created successfully !'); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function render(): View|Application|Factory|\Illuminate\View\View |
|
72
|
|
|
{ |
|
73
|
|
|
return view('livewire.admin.permission.create-permission'); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.