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 | * Construct the repository class name for current model. |
||
72 | * |
||
73 | * @param string $type |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | protected function getRepositoryClassName($type) |
||
81 | |||
82 | /** |
||
83 | * Get repository for updating / modifying data. |
||
84 | * |
||
85 | * @param User|null $user |
||
86 | * |
||
87 | * @return RepositoryUpdater |
||
88 | */ |
||
89 | public function updater(User $user = null) |
||
99 | |||
100 | /** |
||
101 | * get repository class for counting records. |
||
102 | * |
||
103 | * @return Repository |
||
104 | */ |
||
105 | public function counter() |
||
111 | |||
112 | /** |
||
113 | * Get repository class for fetching data. |
||
114 | * |
||
115 | * @return Repository |
||
116 | */ |
||
117 | public function fetcher() |
||
123 | |||
124 | /** |
||
125 | * Attempt to proxy the method call to other related classes if possible. |
||
126 | * |
||
127 | * @param string $name |
||
128 | * @param array $arguments |
||
129 | * |
||
130 | * @return mixed |
||
131 | */ |
||
132 | public function __call($name, $arguments) |
||
148 | |||
149 | /** |
||
150 | * Return instance of the current class. |
||
151 | * |
||
152 | * @param array $attributes |
||
153 | * |
||
154 | * @return static |
||
155 | */ |
||
156 | public static function instance(array $attributes = []) |
||
163 | |||
164 | /** |
||
165 | * Returns the aggregate value of a field. |
||
166 | * |
||
167 | * @param string $field |
||
168 | * |
||
169 | * @return int |
||
170 | */ |
||
171 | protected function getCountAttribute($field) |
||
183 | } |
||
184 |