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) |
||
69 | |||
70 | /** |
||
71 | * @param string $type |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | protected function getRepositoryClassName($type) |
||
79 | |||
80 | /** |
||
81 | * Get repository for updating / modifying data. |
||
82 | * |
||
83 | * @param User|null $user |
||
84 | * |
||
85 | * @return RepositoryUpdater |
||
86 | */ |
||
87 | public function updater(User $user = null) |
||
97 | |||
98 | /** |
||
99 | * get repository class for counting records. |
||
100 | * |
||
101 | * @return Repository |
||
102 | */ |
||
103 | public function counter() |
||
109 | |||
110 | /** |
||
111 | * Get repository class for fetching data. |
||
112 | * |
||
113 | * @return Repository |
||
114 | */ |
||
115 | public function fetcher() |
||
121 | |||
122 | /** |
||
123 | * Attempt to proxy the method call to other related classes if possible. |
||
124 | * |
||
125 | * @param string $name |
||
126 | * @param array $arguments |
||
127 | * |
||
128 | * @return mixed |
||
129 | */ |
||
130 | public function __call($name, $arguments) |
||
152 | |||
153 | /** |
||
154 | * Return instance of the current class. |
||
155 | * |
||
156 | * @param array $attributes |
||
157 | * |
||
158 | * @return static |
||
159 | */ |
||
160 | public static function instance(array $attributes = []) |
||
167 | |||
168 | /** |
||
169 | * Returns the aggregate value of a field. |
||
170 | * |
||
171 | * @param string $field |
||
172 | * |
||
173 | * @return int |
||
174 | */ |
||
175 | protected function getCountAttribute($field) |
||
187 | } |
||
188 |