1 | <?php declare(strict_types = 1); |
||||
2 | |||||
3 | namespace Thinktomorrow\ChiefSitestructure\Breadcrumbs; |
||||
4 | |||||
5 | use Illuminate\Http\Request; |
||||
6 | use Thinktomorrow\Chief\Fields\Fields; |
||||
7 | use Thinktomorrow\Chief\Urls\UrlHelper; |
||||
8 | use Thinktomorrow\Chief\Management\Manager; |
||||
9 | use Thinktomorrow\Chief\Fields\Types\SelectField; |
||||
10 | use Thinktomorrow\ChiefSitestructure\SiteStructure; |
||||
11 | use Thinktomorrow\Chief\Management\Assistants\Assistant; |
||||
12 | |||||
13 | class BreadcrumbAssistant implements Assistant |
||||
14 | { |
||||
15 | private $manager; |
||||
16 | |||||
17 | public function manager(Manager $manager) |
||||
18 | { |
||||
19 | $this->manager = $manager; |
||||
20 | } |
||||
21 | |||||
22 | public static function key(): string |
||||
23 | { |
||||
24 | return 'breadcrumbs'; |
||||
25 | } |
||||
26 | |||||
27 | public function route($verb): ?string |
||||
28 | { |
||||
29 | return null; |
||||
30 | } |
||||
31 | |||||
32 | public function fields(): Fields |
||||
33 | { |
||||
34 | return new Fields([ |
||||
35 | SelectField::make('parent_page') |
||||
36 | ->options(UrlHelper::allModelsExcept($this->manager->modelInstance())) |
||||
37 | ->selected(app(Breadcrumbs::class)->getParentForPage($this->manager->modelInstance())) |
||||
38 | ->grouped() |
||||
39 | ->label('De pagina waar deze pagina onder hoort.'), |
||||
40 | ]); |
||||
41 | } |
||||
42 | |||||
43 | public function saveParentPageField($field, Request $request) |
||||
0 ignored issues
–
show
|
|||||
44 | { |
||||
45 | app(SiteStructure::class)->save($this->manager->existingModel()->flatreference()->get(), $request->input('parent_page') ?? null); |
||||
46 | } |
||||
47 | |||||
48 | public function can($verb): bool |
||||
49 | { |
||||
50 | return true; |
||||
51 | } |
||||
52 | |||||
53 | public function guard($verb): Assistant |
||||
0 ignored issues
–
show
The parameter
$verb 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. ![]() |
|||||
54 | { |
||||
55 | return $this; |
||||
56 | } |
||||
57 | } |
||||
58 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.