Conditions | 3 |
Paths | 1 |
Total Lines | 13 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public function withOnly($relation, $columns = null, $with_trashed = false) |
||
17 | { |
||
18 | $this->model = $this->model->with([$relation => function ($query) use ($columns, $with_trashed) { |
||
|
|||
19 | if ($with_trashed) { |
||
20 | $query->withTrashed(); |
||
21 | } |
||
22 | if ($columns) { |
||
23 | $query->select(array_merge(['id'], $columns)); |
||
24 | } |
||
25 | }]); |
||
26 | |||
27 | return $this; |
||
28 | } |
||
29 | } |
||
30 |
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: