1 | <?php |
||
31 | abstract class ModelAbstract extends Model |
||
32 | { |
||
33 | /** |
||
34 | * @var RepositoryUpdater |
||
35 | */ |
||
36 | protected $updater; |
||
37 | |||
38 | /** |
||
39 | * @var Repository |
||
40 | */ |
||
41 | protected $counter; |
||
42 | |||
43 | /** |
||
44 | * @var Repository |
||
45 | */ |
||
46 | protected $fetcher; |
||
47 | |||
48 | /** |
||
49 | * Factory method to instantiate a repository class based on a type. |
||
50 | * |
||
51 | * @param string $type |
||
52 | * |
||
53 | * @return Repository|RepositoryUpdater |
||
54 | */ |
||
55 | protected function factoryRepository($type) |
||
68 | |||
69 | /** |
||
70 | * @param string $type |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | protected function getRepositoryClassName($type) |
||
78 | |||
79 | /** |
||
80 | * Get repository for updating / modifying data. |
||
81 | * |
||
82 | * @param User|null $user |
||
83 | * |
||
84 | * @return RepositoryUpdater |
||
85 | */ |
||
86 | public function updater(User $user = null) |
||
94 | |||
95 | /** |
||
96 | * get repository class for counting records. |
||
97 | * |
||
98 | * @return Repository |
||
99 | */ |
||
100 | public function counter() |
||
106 | |||
107 | /** |
||
108 | * Get repository class for fetching data. |
||
109 | * |
||
110 | * @return Repository |
||
111 | */ |
||
112 | public function fetcher() |
||
118 | |||
119 | /** |
||
120 | * Attempt to proxy the method call to other related classes if possible. |
||
121 | * |
||
122 | * @param string $name |
||
123 | * @param array $arguments |
||
124 | * |
||
125 | * @return mixed |
||
126 | */ |
||
127 | public function __call($name, $arguments) |
||
149 | |||
150 | /** |
||
151 | * Return instance of the current class. |
||
152 | * |
||
153 | * @param array $attributes |
||
154 | * |
||
155 | * @return static |
||
156 | */ |
||
157 | public static function instance(array $attributes = []) |
||
164 | |||
165 | /** |
||
166 | * Returns the aggregate value of a field. |
||
167 | * |
||
168 | * @param string $field |
||
169 | * |
||
170 | * @return int |
||
171 | */ |
||
172 | protected function getCountAttribute($field) |
||
184 | } |
||
185 |