|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Xetaravel\Livewire\Admin\Blog; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Contracts\View\Factory; |
|
6
|
|
|
use Illuminate\Contracts\View\View; |
|
7
|
|
|
use Illuminate\Foundation\Application; |
|
8
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
|
9
|
|
|
use Livewire\Attributes\On; |
|
10
|
|
|
use Livewire\Component; |
|
11
|
|
|
use Masmerise\Toaster\Toastable; |
|
12
|
|
|
use Xetaravel\Livewire\Forms\BlogCategoryForm; |
|
13
|
|
|
use Xetaravel\Models\BlogCategory; |
|
14
|
|
|
|
|
15
|
|
|
class UpdateCategory extends Component |
|
16
|
|
|
{ |
|
17
|
|
|
use AuthorizesRequests; |
|
18
|
|
|
use Toastable; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* The form used to create/update a model. |
|
22
|
|
|
* |
|
23
|
|
|
* @var BlogCategoryForm |
|
24
|
|
|
*/ |
|
25
|
|
|
public BlogCategoryForm $form; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Used to show the update modal. |
|
29
|
|
|
* |
|
30
|
|
|
* @var bool |
|
31
|
|
|
*/ |
|
32
|
|
|
public bool $showModal = false; |
|
33
|
|
|
|
|
34
|
|
|
public function render(): View|Application|Factory|\Illuminate\View\View |
|
35
|
|
|
{ |
|
36
|
|
|
return view('livewire.admin.blog.update-category'); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* When a user click on 'Edit' open the modal and set the content. |
|
41
|
|
|
* |
|
42
|
|
|
* @param BlogCategory $blogCategory |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
#[On('update-category')] |
|
47
|
|
|
public function updateCategory(BlogCategory $blogCategory): void |
|
48
|
|
|
{ |
|
49
|
|
|
$this->authorize('update', $blogCategory); |
|
50
|
|
|
|
|
51
|
|
|
$this->form->reset(); |
|
52
|
|
|
$this->form->blogCategory = $blogCategory; |
|
53
|
|
|
$this->form->title = $blogCategory->title; |
|
54
|
|
|
$this->form->description = $blogCategory->description; |
|
55
|
|
|
|
|
56
|
|
|
$this->showModal = true; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Update the category. |
|
61
|
|
|
* |
|
62
|
|
|
* @return void |
|
63
|
|
|
*/ |
|
64
|
|
|
public function update(): void |
|
65
|
|
|
{ |
|
66
|
|
|
$this->authorize('update', $this->form->blogCategory); |
|
67
|
|
|
|
|
68
|
|
|
$this->validate(); |
|
69
|
|
|
|
|
70
|
|
|
$this->form->update(); |
|
71
|
|
|
|
|
72
|
|
|
redirect() |
|
73
|
|
|
->route('admin.blog.category.index') |
|
|
|
|
|
|
74
|
|
|
->success('Your category has been updated successfully !'); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
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.