-
Notifications
You must be signed in to change notification settings - Fork 0
/
Builder.php
62 lines (45 loc) · 1.02 KB
/
Builder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Expresser\Support;
use Expresser\Contracts\Support\Queryable;
abstract class Builder
{
protected $query;
protected $model;
public function __construct(Queryable $query)
{
$this->setQuery($query);
}
public function get()
{
$models = $this->getModels();
return $this->model->newCollection($models);
}
public function getModels()
{
$results = $this->query->execute();
return $this->model->hydrate($results)->all();
}
public function getQuery()
{
return $this->query;
}
public function setQuery(Queryable $query)
{
$this->query = $query;
return $this;
}
public function getModel()
{
return $this->model;
}
public function setModel(Model $model)
{
$this->model = $model;
return $this;
}
public function __call($method, $parameters)
{
call_user_func_array([$this->query, $method], $parameters);
return $this;
}
}