1 | <?php |
||
5 | trait OptimusHashidTrait |
||
6 | { |
||
7 | /** |
||
8 | * Get the value of the model's primary key. |
||
9 | * |
||
10 | * @return mixed |
||
11 | */ |
||
12 | abstract public function getKey(); |
||
13 | |||
14 | /** |
||
15 | * Get the table qualified key name. |
||
16 | * |
||
17 | * @return string |
||
18 | */ |
||
19 | abstract public function getQualifiedKeyName(); |
||
20 | |||
21 | /** |
||
22 | * Get the hashid for the given key. |
||
23 | * |
||
24 | * @param mixed $key |
||
25 | * @return mixed |
||
26 | */ |
||
27 | public function getHashidForKey($key) |
||
35 | |||
36 | /** |
||
37 | * Get the key for the given hashid. |
||
38 | * |
||
39 | * @param mixed $hashid |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function getKeyForHashid($hashid) |
||
50 | |||
51 | /** |
||
52 | * Get the `hashid` attribute. |
||
53 | * |
||
54 | * @return int |
||
55 | */ |
||
56 | public function getHashidAttribute() |
||
60 | |||
61 | /** |
||
62 | * Scope a query to user of given hashid. |
||
63 | * |
||
64 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
65 | * @param mixed $hashid |
||
66 | * @return \Illuminate\Database\Eloquent\Builder |
||
67 | */ |
||
68 | public function scopeWhereHashid($query, $hashid) |
||
72 | } |
||
73 |