1 | <?php |
||
12 | class TranslationRepository |
||
13 | { |
||
14 | protected $model; |
||
15 | protected $app; |
||
16 | protected $cache; |
||
17 | protected $errors = null; |
||
18 | |||
19 | /** |
||
20 | * Constructor. |
||
21 | * |
||
22 | * @param Application $app |
||
23 | * @param CacheRepository $cache |
||
24 | */ |
||
25 | public function __construct(Application $app, CacheRepository $cache) |
||
31 | |||
32 | /** |
||
33 | * Return the model related to this finder. |
||
34 | * |
||
35 | * @return \Illuminate\Database\Eloquent\Model |
||
36 | */ |
||
37 | public function getModel() |
||
41 | |||
42 | /** |
||
43 | * Check if the model's table exists. |
||
44 | * |
||
45 | * @return bool |
||
46 | */ |
||
47 | public function tableExists() |
||
51 | |||
52 | /** |
||
53 | * Retrieve all entries. |
||
54 | * |
||
55 | * @param array $related Related object to include. |
||
56 | * @param int $perPage Number of records to retrieve per page. If zero the whole result set is returned. |
||
57 | * |
||
58 | * @return \Illuminate\Database\Eloquent\Model |
||
59 | */ |
||
60 | public function all($related = [], $perPage = 0) |
||
66 | |||
67 | /** |
||
68 | * Retrieve a single entry by id. |
||
69 | * |
||
70 | * @param int $id |
||
71 | * |
||
72 | * @return \Illuminate\Database\Eloquent\Model |
||
73 | */ |
||
74 | public function find($id) |
||
78 | |||
79 | /** |
||
80 | * Remove an entry. |
||
81 | * |
||
82 | * @param string $id |
||
83 | * |
||
84 | * @return bool |
||
85 | */ |
||
86 | public function delete($id) |
||
96 | |||
97 | /** |
||
98 | * Returns total number of entries in DB. |
||
99 | * |
||
100 | * @return int |
||
101 | */ |
||
102 | public function count() |
||
106 | |||
107 | /** |
||
108 | * Return all items for a given namespace and group. |
||
109 | * |
||
110 | * @param string $namespace |
||
111 | * @param string $group |
||
112 | * |
||
113 | * @return \Illuminate\Database\Eloquent\Collection |
||
114 | */ |
||
115 | public function getItems($namespace, $group) |
||
122 | |||
123 | /** |
||
124 | * Return a specific item with its translation for a given namespace, group and key. |
||
125 | * |
||
126 | * @param string $namespace |
||
127 | * @param string $group |
||
128 | * @param string $key |
||
129 | * |
||
130 | * @return \Illuminate\Database\Eloquent\Builder |
||
131 | */ |
||
132 | public function getItem($namespace, $group, $key) |
||
140 | |||
141 | /** |
||
142 | * Insert a new translation into the database. |
||
143 | * If the attributes are not valid. |
||
144 | * |
||
145 | * @param array $attributes |
||
146 | * |
||
147 | * @return bool |
||
148 | **/ |
||
149 | public function create(array $attributes) |
||
153 | |||
154 | /** |
||
155 | * Update the translations of an existing key and locale by id. |
||
156 | * |
||
157 | * @param int $id |
||
158 | * @param string $locale |
||
159 | * @param string $value |
||
160 | * @param bool $overwrite |
||
161 | * |
||
162 | * @return bool |
||
163 | **/ |
||
164 | public function updateById($id, $locale, $value, $overwrite = true) : bool |
||
169 | |||
170 | /** |
||
171 | * Update the translations of an existing key and locale. |
||
172 | * |
||
173 | * @param Translation $line |
||
174 | * @param string $locale |
||
175 | * @param string $value |
||
176 | * @param bool $overwrite |
||
177 | * |
||
178 | * @return bool |
||
179 | **/ |
||
180 | public function updateTranslation(Translation $line, $locale, $value, $overwrite = true) : bool |
||
188 | |||
189 | /** |
||
190 | * @param Translation $translation |
||
191 | * @return bool |
||
192 | */ |
||
193 | public function save(Translation $translation) : bool |
||
197 | |||
198 | /** |
||
199 | * Validate the given attributes. |
||
200 | * |
||
201 | * @param array $attributes |
||
202 | * |
||
203 | * @return bool |
||
204 | */ |
||
205 | public function validate(array $attributes) : bool |
||
226 | } |
||
227 |