1 | <?php |
||||
2 | |||||
3 | namespace App\Observers; |
||||
4 | |||||
5 | |||||
6 | use App\Src\UseCases\Infra\Sql\Model\CharacteristicsModel; |
||||
7 | use App\Src\UseCases\Infra\Sql\Model\PageModel; |
||||
8 | use App\Src\UseCases\Infra\Sql\Model\UserCharacteristicsModel; |
||||
9 | use Illuminate\Support\Facades\DB; |
||||
10 | use Illuminate\Support\Facades\Log; |
||||
11 | |||||
12 | class PageObserver |
||||
13 | { |
||||
14 | public function created(PageModel $pageModel) |
||||
0 ignored issues
–
show
|
|||||
15 | { |
||||
16 | // |
||||
17 | } |
||||
18 | |||||
19 | public function updated(PageModel $pageModel) |
||||
0 ignored issues
–
show
The parameter
$pageModel is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
20 | { |
||||
21 | // |
||||
22 | } |
||||
23 | |||||
24 | public function deleted(PageModel $pageModel) |
||||
25 | { |
||||
26 | Log::info('Deleting all data from the page internal id: ' . $pageModel->id); |
||||
27 | DB::transaction(function () use($pageModel){ |
||||
28 | try { |
||||
29 | $characteristic = CharacteristicsModel::query()->where('page_id', $pageModel->page_id)->first(); |
||||
30 | if (isset($characteristic)) { |
||||
31 | $characteristic->delete(); |
||||
32 | if (is_file($characteristic->picturePath())) { |
||||
33 | unlink($characteristic->picturePath()); |
||||
34 | } |
||||
35 | |||||
36 | UserCharacteristicsModel::query()->where('characteristic_id', $characteristic->id)->delete(); |
||||
37 | } |
||||
38 | } catch (\Throwable $e) { |
||||
39 | Log::emergency('Error deleting all data from the page internal id: ' . $pageModel->id); |
||||
40 | throw $e; |
||||
41 | } |
||||
42 | }); |
||||
43 | } |
||||
44 | |||||
45 | public function restored(PageModel $pageModel) |
||||
0 ignored issues
–
show
The parameter
$pageModel is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
46 | { |
||||
47 | // |
||||
48 | } |
||||
49 | |||||
50 | public function forceDeleted(PageModel $pageModel) |
||||
0 ignored issues
–
show
The parameter
$pageModel is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||
51 | { |
||||
52 | // |
||||
53 | } |
||||
54 | } |
||||
55 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.