1 | <?php namespace Cviebrock\EloquentSluggable; |
||
13 | trait Sluggable |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * Hook into the Eloquent model events to create or |
||
18 | * update the slug as required. |
||
19 | */ |
||
20 | public static function bootSluggable(): void |
||
24 | |||
25 | /** |
||
26 | * Register a slugging model event with the dispatcher. |
||
27 | * |
||
28 | * @param \Closure|string $callback |
||
29 | */ |
||
30 | public static function slugging($callback): void |
||
34 | |||
35 | /** |
||
36 | * Register a slugged model event with the dispatcher. |
||
37 | * |
||
38 | * @param \Closure|string $callback |
||
39 | */ |
||
40 | public static function slugged($callback): void |
||
44 | |||
45 | /** |
||
46 | * @inheritDoc |
||
47 | */ |
||
48 | public function replicate(array $except = null) |
||
55 | |||
56 | /** |
||
57 | * Return the event name that should be listened to for generating slugs. |
||
58 | * |
||
59 | * Can be one of: |
||
60 | * - SluggableObserver::SAVING (to generate the slug before the model is saved) |
||
61 | * - SluggableObserver::SAVED (to generate the slug after the model is saved) |
||
62 | * |
||
63 | * The second option is required if the primary key is to be part of the slug |
||
64 | * source, as it won't be set during the "saving" event. |
||
65 | * |
||
66 | * @return string |
||
67 | */ |
||
68 | public function sluggableEvent(): string |
||
72 | |||
73 | /** |
||
74 | * Query scope for finding "similar" slugs, used to determine uniqueness. |
||
75 | * |
||
76 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
77 | * @param string $attribute |
||
78 | * @param array $config |
||
79 | * @param string $slug |
||
80 | * @return \Illuminate\Database\Eloquent\Builder |
||
81 | */ |
||
82 | public function scopeFindSimilarSlugs(Builder $query, string $attribute, array $config, string $slug): Builder |
||
91 | |||
92 | /** |
||
93 | * Return the sluggable configuration array for this model. |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | abstract public function sluggable(): array; |
||
98 | |||
99 | |||
100 | /** |
||
101 | * Optionally customize the cocur/slugify engine. |
||
102 | * |
||
103 | * @param \Cocur\Slugify\Slugify $engine |
||
104 | * @param string $attribute |
||
105 | * @return \Cocur\Slugify\Slugify |
||
106 | */ |
||
107 | public function customizeSlugEngine(Slugify $engine, string $attribute): Slugify |
||
111 | |||
112 | /** |
||
113 | * Optionally add constraints to the query that determines uniqueness. |
||
114 | * |
||
115 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
116 | * @param \Illuminate\Database\Eloquent\Model $model |
||
117 | * @param string $attribute |
||
118 | * @param array $config |
||
119 | * @param string $slug |
||
120 | * @return \Illuminate\Database\Eloquent\Builder |
||
121 | */ |
||
122 | public function scopeWithUniqueSlugConstraints( |
||
132 | } |
||
133 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.