1 | <?php |
||
7 | trait Castable |
||
8 | { |
||
9 | /** |
||
10 | * Casts either a collection or a single model. |
||
11 | * |
||
12 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
13 | * @param \Koch\Casters\Contracts\Caster|null $caster |
||
14 | * @return array |
||
15 | */ |
||
16 | public function scopeCast($query, Caster $caster = null) |
||
26 | |||
27 | /** |
||
28 | * Resolves the caster name and returns its instance. |
||
29 | * |
||
30 | * @return \Koch\Casters\Contracts\Caster |
||
31 | */ |
||
32 | protected function findCaster() |
||
42 | } |
||
43 |
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: