1 | <?php |
||
5 | abstract class RepositoryAbstract |
||
6 | { |
||
7 | /** |
||
8 | * @var \Illuminate\Database\Eloquent\Model |
||
9 | */ |
||
10 | protected $model; |
||
11 | |||
12 | /** |
||
13 | * Handle dynamic static method calls into the method. |
||
14 | * |
||
15 | * @param string $method |
||
16 | * @param array $parameters |
||
17 | * @return mixed |
||
18 | */ |
||
19 | public static function __callStatic($method, $parameters) |
||
20 | { |
||
21 | $instance = new static; |
||
22 | $class = get_class($instance->getModel()); |
||
23 | $model = new $class; |
||
24 | |||
25 | return call_user_func_array([$model, $method], $parameters); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Get repository model. |
||
30 | * |
||
31 | * @return \Illuminate\Database\Eloquent\Model |
||
32 | */ |
||
33 | abstract public function getModel(); |
||
34 | |||
35 | /** |
||
36 | * Handle dynamic method calls into the model. |
||
37 | * |
||
38 | * @param string $method |
||
39 | * @param array $parameters |
||
40 | * @return mixed |
||
41 | */ |
||
42 | public function __call($method, $parameters) |
||
46 | } |
||
47 |