1 | <?php |
||
7 | abstract class BaseService implements BaseServiceInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var object |
||
11 | */ |
||
12 | public $repo; |
||
13 | |||
14 | /** |
||
15 | * Init new object. |
||
16 | * |
||
17 | * @param mixed $repo |
||
18 | * @return void |
||
|
|||
19 | */ |
||
20 | public function __construct($repo) |
||
24 | |||
25 | /** |
||
26 | * Fetch records with relations based on the given params. |
||
27 | * |
||
28 | * @param array $relations |
||
29 | * @param array $conditions |
||
30 | * @param integer $perPage |
||
31 | * @param string $sortBy |
||
32 | * @param boolean $desc |
||
33 | * @param boolean $trashed |
||
34 | * @return collection |
||
35 | */ |
||
36 | public function list($relations = [], $conditions = false, $perPage = 15, $sortBy = 'created_at', $desc = true, $trashed = false) |
||
52 | |||
53 | /** |
||
54 | * Fetch all records with relations from the storage. |
||
55 | * |
||
56 | * @param array $relations |
||
57 | * @param string $sortBy |
||
58 | * @param boolean $desc |
||
59 | * @param array $columns |
||
60 | * @return collection |
||
61 | */ |
||
62 | public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
66 | |||
67 | /** |
||
68 | * Fetch all records with relations from storage in pages. |
||
69 | * |
||
70 | * @param integer $perPage |
||
71 | * @param array $relations |
||
72 | * @param string $sortBy |
||
73 | * @param boolean $desc |
||
74 | * @param array $columns |
||
75 | * @return collection |
||
76 | */ |
||
77 | public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
81 | |||
82 | /** |
||
83 | * Fetch all records with relations based on |
||
84 | * the given condition from storage in pages. |
||
85 | * |
||
86 | * @param array $conditions array of conditions |
||
87 | * @param integer $perPage |
||
88 | * @param array $relations |
||
89 | * @param string $sortBy |
||
90 | * @param boolean $desc |
||
91 | * @param array $columns |
||
92 | * @return collection |
||
93 | */ |
||
94 | public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
98 | |||
99 | /** |
||
100 | * Save the given model to the storage. |
||
101 | * |
||
102 | * @param array $data |
||
103 | * @return mixed |
||
104 | */ |
||
105 | public function save(array $data) |
||
109 | |||
110 | /** |
||
111 | * Delete record from the storage based on the given |
||
112 | * condition. |
||
113 | * |
||
114 | * @param var $value condition value |
||
115 | * @param string $attribute condition column name |
||
116 | * @return void |
||
117 | */ |
||
118 | public function delete($value, $attribute = 'id') |
||
122 | |||
123 | /** |
||
124 | * Fetch records from the storage based on the given |
||
125 | * id. |
||
126 | * |
||
127 | * @param integer $id |
||
128 | * @param array $relations |
||
129 | * @param array $columns |
||
130 | * @return object |
||
131 | */ |
||
132 | public function find($id, $relations = [], $columns = ['*']) |
||
136 | |||
137 | /** |
||
138 | * Fetch records from the storage based on the given |
||
139 | * condition. |
||
140 | * |
||
141 | * @param array $conditions array of conditions |
||
142 | * @param array $relations |
||
143 | * @param string $sortBy |
||
144 | * @param boolean $desc |
||
145 | * @param array $columns |
||
146 | * @return collection |
||
147 | */ |
||
148 | public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
152 | |||
153 | /** |
||
154 | * Fetch the first record from the storage based on the given |
||
155 | * condition. |
||
156 | * |
||
157 | * @param array $conditions array of conditions |
||
158 | * @param array $relations |
||
159 | * @param array $columns |
||
160 | * @return object |
||
161 | */ |
||
162 | public function first($conditions, $relations = [], $columns = ['*']) |
||
166 | |||
167 | /** |
||
168 | * Return the deleted models in pages based on the given conditions. |
||
169 | * |
||
170 | * @param array $conditions array of conditions |
||
171 | * @param integer $perPage |
||
172 | * @param string $sortBy |
||
173 | * @param boolean $desc |
||
174 | * @param array $columns |
||
175 | * @return collection |
||
176 | */ |
||
177 | public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
181 | |||
182 | /** |
||
183 | * Restore the deleted model. |
||
184 | * |
||
185 | * @param integer $id |
||
186 | * @return void |
||
187 | */ |
||
188 | public function restore($id) |
||
192 | |||
193 | /** |
||
194 | * Prepare filters for repo. |
||
195 | * |
||
196 | * @param array $conditions |
||
197 | * @return array |
||
198 | */ |
||
199 | public function constructFilters($conditions) |
||
228 | } |
||
229 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.