1 | <?php |
||
2 | |||
3 | namespace Volosyuk\SimpleEloquent; |
||
4 | |||
5 | use Illuminate\Support\Collection; |
||
6 | use stdClass; |
||
7 | use Volosyuk\SimpleEloquent\Relations\HasRelationships; |
||
8 | |||
9 | /** |
||
10 | * Trait SimpleEloquent |
||
11 | * |
||
12 | * @package Volosyuk\SimpleEloquent |
||
13 | * @authour Volosyuk Andrey <[email protected]> |
||
14 | */ |
||
15 | trait SimpleEloquent |
||
16 | { |
||
17 | use HasRelationships; |
||
18 | |||
19 | /** |
||
20 | * Create a new Eloquent query builder for the model. |
||
21 | * |
||
22 | * @param Builder $query |
||
23 | * @return Builder|static |
||
24 | */ |
||
25 | 33 | public function newEloquentBuilder($query) |
|
26 | { |
||
27 | 33 | return new Builder($query); |
|
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Get all of the models from the database. |
||
32 | * |
||
33 | * @param array|mixed $columns |
||
34 | * @return Collection|stdClass[]|array |
||
35 | */ |
||
36 | 1 | public static function allSimple($columns = ['*']) |
|
37 | { |
||
38 | 1 | $columns = is_array($columns) ? $columns : func_get_args(); |
|
39 | |||
40 | /** |
||
41 | * @var Builder $query |
||
42 | */ |
||
43 | 1 | $query = (new static)->newQuery(); |
|
44 | |||
45 | 1 | return $query->simple()->get($columns); |
|
46 | } |
||
47 | } |
||
48 |