1 | <?php |
||
9 | trait Incrementable |
||
10 | { |
||
11 | /** |
||
12 | * Boot the Incrementable trait for a model. |
||
13 | * |
||
14 | * @return void |
||
15 | */ |
||
16 | public static function bootIncrementable() |
||
22 | |||
23 | /** |
||
24 | * Determine and set the increment value. |
||
25 | */ |
||
26 | public function setIncrementableValue() |
||
32 | |||
33 | /** |
||
34 | * Get the increment field, throws an exception when missing. |
||
35 | * |
||
36 | * @return string |
||
37 | * |
||
38 | * @throws \ByTestGear\Incrementable\Exceptions\MissingIncrementableDefinition |
||
39 | */ |
||
40 | protected function getIncrementableField(): string |
||
48 | |||
49 | /** |
||
50 | * Gets the next available value for a new model. |
||
51 | * |
||
52 | * @return int |
||
53 | */ |
||
54 | protected function getNextIncrementableValue(): int |
||
58 | |||
59 | /** |
||
60 | * Gets the highest available value currently available. |
||
61 | * |
||
62 | * @return int |
||
63 | */ |
||
64 | protected function getHighestIncrementableValue(): int |
||
74 | |||
75 | /** |
||
76 | * Build incrementable query group. |
||
77 | * |
||
78 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
79 | * |
||
80 | * @return \Illuminate\Database\Eloquent\Builder |
||
81 | */ |
||
82 | public function buildIncrementableGroupQuery(Builder $query) |
||
92 | |||
93 | /** |
||
94 | * Build incrementable query. Supports soft-deletes. |
||
95 | * |
||
96 | * @return \Illuminate\Database\Eloquent\Builder |
||
97 | */ |
||
98 | public function buildIncrementableQuery() |
||
106 | } |
||
107 |
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: