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) |
||
59 | |||
60 | /** |
||
61 | * Fetch all records with relations from the storage. |
||
62 | * |
||
63 | * @param array $relations |
||
64 | * @param string $sortBy |
||
65 | * @param boolean $desc |
||
66 | * @param array $columns |
||
67 | * @return collection |
||
68 | */ |
||
69 | public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
73 | |||
74 | /** |
||
75 | * Fetch all records with relations from storage in pages. |
||
76 | * |
||
77 | * @param integer $perPage |
||
78 | * @param array $relations |
||
79 | * @param string $sortBy |
||
80 | * @param boolean $desc |
||
81 | * @param array $columns |
||
82 | * @return collection |
||
83 | */ |
||
84 | public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
88 | |||
89 | /** |
||
90 | * Fetch all records with relations based on |
||
91 | * the given condition from storage in pages. |
||
92 | * |
||
93 | * @param array $conditions array of conditions |
||
94 | * @param integer $perPage |
||
95 | * @param array $relations |
||
96 | * @param string $sortBy |
||
97 | * @param boolean $desc |
||
98 | * @param array $columns |
||
99 | * @return collection |
||
100 | */ |
||
101 | public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
105 | |||
106 | /** |
||
107 | * Save the given model to the storage. |
||
108 | * |
||
109 | * @param array $data |
||
110 | * @return mixed |
||
111 | */ |
||
112 | public function save(array $data) |
||
116 | |||
117 | /** |
||
118 | * Delete record from the storage based on the given |
||
119 | * condition. |
||
120 | * |
||
121 | * @param var $value condition value |
||
122 | * @param string $attribute condition column name |
||
123 | * @return void |
||
124 | */ |
||
125 | public function delete($value, $attribute = 'id') |
||
129 | |||
130 | /** |
||
131 | * Fetch records from the storage based on the given |
||
132 | * id. |
||
133 | * |
||
134 | * @param integer $id |
||
135 | * @param array $relations |
||
136 | * @param array $columns |
||
137 | * @return object |
||
138 | */ |
||
139 | public function find($id, $relations = [], $columns = ['*']) |
||
143 | |||
144 | /** |
||
145 | * Fetch records from the storage based on the given |
||
146 | * condition. |
||
147 | * |
||
148 | * @param array $conditions array of conditions |
||
149 | * @param array $relations |
||
150 | * @param string $sortBy |
||
151 | * @param boolean $desc |
||
152 | * @param array $columns |
||
153 | * @return collection |
||
154 | */ |
||
155 | public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
159 | |||
160 | /** |
||
161 | * Fetch the first record from the storage based on the given |
||
162 | * condition. |
||
163 | * |
||
164 | * @param array $conditions array of conditions |
||
165 | * @param array $relations |
||
166 | * @param array $columns |
||
167 | * @return object |
||
168 | */ |
||
169 | public function first($conditions, $relations = [], $columns = ['*']) |
||
173 | |||
174 | /** |
||
175 | * Return the deleted models in pages based on the given conditions. |
||
176 | * |
||
177 | * @param array $conditions array of conditions |
||
178 | * @param integer $perPage |
||
179 | * @param string $sortBy |
||
180 | * @param boolean $desc |
||
181 | * @param array $columns |
||
182 | * @return collection |
||
183 | */ |
||
184 | public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*']) |
||
188 | |||
189 | /** |
||
190 | * Restore the deleted model. |
||
191 | * |
||
192 | * @param integer $id |
||
193 | * @return void |
||
194 | */ |
||
195 | public function restore($id) |
||
199 | } |
||
200 |
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.