1 | <?php namespace Cviebrock\EloquentSluggable; |
||
11 | trait SluggableScopeHelpers |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Primary slug column of this model. |
||
16 | * |
||
17 | * @return string |
||
18 | */ |
||
19 | public function getSlugKeyName() |
||
29 | |||
30 | /** |
||
31 | * Primary slug value of this model. |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | public function getSlugKey() |
||
39 | |||
40 | /** |
||
41 | * Query scope for finding a model by its primary slug. |
||
42 | * |
||
43 | * @param \Illuminate\Database\Eloquent\Builder $scope |
||
44 | * @param string $slug |
||
45 | * @return \Illuminate\Database\Eloquent\Builder |
||
46 | */ |
||
47 | public function scopeWhereSlug($scope, $slug) |
||
51 | |||
52 | /** |
||
53 | * Find a model by its primary slug. |
||
54 | * |
||
55 | * @param string $slug |
||
56 | * @param array $columns |
||
57 | * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|static[]|static|null |
||
58 | */ |
||
59 | public static function findBySlug($slug, array $columns = ['*']) |
||
63 | |||
64 | /** |
||
65 | * Find a model by its primary slug or throw an exception. |
||
66 | * |
||
67 | * @param string $slug |
||
68 | * @param array $columns |
||
69 | * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection |
||
70 | * |
||
71 | * @throws \Illuminate\Database\Eloquent\ModelNotFoundException |
||
72 | */ |
||
73 | public static function findBySlugOrFail($slug, array $columns = ['*']) |
||
77 | } |
||
78 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: