Completed
Push — master ( 91df31...876b8b )
by Sherif
01:12
created
PushNotificationDevices/Http/Requests/StorePushNotificationDevice.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,27 +6,27 @@
 block discarded – undo
6 6
 
7 7
 class StorePushNotificationDevice extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        $requiredOrNullable = request()->isMethod('PATCH') ? 'nullable' : 'required' . '';
27
-        return [
28
-            'device_token' => $requiredOrNullable . '|string|max:255',
29
-            'user_id'      => $requiredOrNullable . '|exists:users,id'
30
-        ];
31
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		$requiredOrNullable = request()->isMethod('PATCH') ? 'nullable' : 'required' . '';
27
+		return [
28
+			'device_token' => $requiredOrNullable . '|string|max:255',
29
+			'user_id'      => $requiredOrNullable . '|exists:users,id'
30
+		];
31
+	}
32 32
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -23,10 +23,10 @@
 block discarded – undo
23 23
      */
24 24
     public function rules()
25 25
     {
26
-        $requiredOrNullable = request()->isMethod('PATCH') ? 'nullable' : 'required' . '';
26
+        $requiredOrNullable = request()->isMethod('PATCH') ? 'nullable' : 'required'.'';
27 27
         return [
28
-            'device_token' => $requiredOrNullable . '|string|max:255',
29
-            'user_id'      => $requiredOrNullable . '|exists:users,id'
28
+            'device_token' => $requiredOrNullable.'|string|max:255',
29
+            'user_id'      => $requiredOrNullable.'|exists:users,id'
30 30
         ];
31 31
     }
32 32
 }
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseService.php 2 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -7,250 +7,250 @@
 block discarded – undo
7 7
 
8 8
 abstract class BaseService implements BaseServiceInterface
9 9
 {
10
-    /**
11
-     * @var object
12
-     */
13
-    public $repo;
10
+	/**
11
+	 * @var object
12
+	 */
13
+	public $repo;
14 14
 
15
-    /**
16
-     * Init new object.
17
-     *
18
-     * @param   mixed  $repo
19
-     * @return  void
20
-     */
21
-    public function __construct($repo)
22
-    {
23
-        $this->repo = $repo;
24
-    }
15
+	/**
16
+	 * Init new object.
17
+	 *
18
+	 * @param   mixed  $repo
19
+	 * @return  void
20
+	 */
21
+	public function __construct($repo)
22
+	{
23
+		$this->repo = $repo;
24
+	}
25 25
 
26
-    /**
27
-     * Fetch records with relations based on the given params.
28
-     *
29
-     * @param   array   $relations
30
-     * @param   array   $conditions
31
-     * @param   integer $perPage
32
-     * @param   string  $sortBy
33
-     * @param   boolean $desc
34
-     * @param   boolean $trashed
35
-     * @return collection
36
-     */
37
-    public function list($relations = [], $conditions = false, $perPage = 15, $sortBy = 'created_at', $desc = true, $trashed = false)
38
-    {
39
-        $translatable = $this->repo->model->translatable ?? [];
40
-        $filters = $this->constructFilters($conditions);
41
-        $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . Session::get('locale') : $sortBy;
26
+	/**
27
+	 * Fetch records with relations based on the given params.
28
+	 *
29
+	 * @param   array   $relations
30
+	 * @param   array   $conditions
31
+	 * @param   integer $perPage
32
+	 * @param   string  $sortBy
33
+	 * @param   boolean $desc
34
+	 * @param   boolean $trashed
35
+	 * @return collection
36
+	 */
37
+	public function list($relations = [], $conditions = false, $perPage = 15, $sortBy = 'created_at', $desc = true, $trashed = false)
38
+	{
39
+		$translatable = $this->repo->model->translatable ?? [];
40
+		$filters = $this->constructFilters($conditions);
41
+		$sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . Session::get('locale') : $sortBy;
42 42
 
43
-        if ($trashed) {
44
-            return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
45
-        }
43
+		if ($trashed) {
44
+			return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
45
+		}
46 46
         
47
-        if (count($filters)) {
48
-            return $this->paginateBy(['and' => $filters], $perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
49
-        }
47
+		if (count($filters)) {
48
+			return $this->paginateBy(['and' => $filters], $perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
49
+		}
50 50
 
51
-        return $this->paginate($perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
52
-    }
51
+		return $this->paginate($perPage ?? 15, $relations, $sortBy ?? 'created_at', $desc ?? true);
52
+	}
53 53
 
54
-    /**
55
-     * Fetch all records with relations from the storage.
56
-     *
57
-     * @param  array   $relations
58
-     * @param  string  $sortBy
59
-     * @param  boolean $desc
60
-     * @param  array   $columns
61
-     * @return collection
62
-     */
63
-    public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
64
-    {
65
-        return $this->repo->all($relations, $sortBy, $desc, $columns);
66
-    }
54
+	/**
55
+	 * Fetch all records with relations from the storage.
56
+	 *
57
+	 * @param  array   $relations
58
+	 * @param  string  $sortBy
59
+	 * @param  boolean $desc
60
+	 * @param  array   $columns
61
+	 * @return collection
62
+	 */
63
+	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
64
+	{
65
+		return $this->repo->all($relations, $sortBy, $desc, $columns);
66
+	}
67 67
     
68
-    /**
69
-     * Fetch all records with relations from storage in pages.
70
-     *
71
-     * @param  integer $perPage
72
-     * @param  array   $relations
73
-     * @param  string  $sortBy
74
-     * @param  boolean $desc
75
-     * @param  array   $columns
76
-     * @return collection
77
-     */
78
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
79
-    {
80
-        return $this->repo->paginate($perPage, $relations, $sortBy, $desc, $columns);
81
-    }
68
+	/**
69
+	 * Fetch all records with relations from storage in pages.
70
+	 *
71
+	 * @param  integer $perPage
72
+	 * @param  array   $relations
73
+	 * @param  string  $sortBy
74
+	 * @param  boolean $desc
75
+	 * @param  array   $columns
76
+	 * @return collection
77
+	 */
78
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
79
+	{
80
+		return $this->repo->paginate($perPage, $relations, $sortBy, $desc, $columns);
81
+	}
82 82
 
83
-    /**
84
-     * Fetch all records with relations based on
85
-     * the given condition from storage in pages.
86
-     *
87
-     * @param  array   $conditions array of conditions
88
-     * @param  integer $perPage
89
-     * @param  array   $relations
90
-     * @param  string  $sortBy
91
-     * @param  boolean $desc
92
-     * @param  array   $columns
93
-     * @return collection
94
-     */
95
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
96
-    {
97
-        return $this->repo->paginateBy($conditions, $perPage, $relations, $sortBy, $desc, $columns);
98
-    }
83
+	/**
84
+	 * Fetch all records with relations based on
85
+	 * the given condition from storage in pages.
86
+	 *
87
+	 * @param  array   $conditions array of conditions
88
+	 * @param  integer $perPage
89
+	 * @param  array   $relations
90
+	 * @param  string  $sortBy
91
+	 * @param  boolean $desc
92
+	 * @param  array   $columns
93
+	 * @return collection
94
+	 */
95
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
96
+	{
97
+		return $this->repo->paginateBy($conditions, $perPage, $relations, $sortBy, $desc, $columns);
98
+	}
99 99
     
100
-    /**
101
-     * Save the given model to the storage.
102
-     *
103
-     * @param  array $data
104
-     * @return mixed
105
-     */
106
-    public function save(array $data)
107
-    {
108
-        return $this->repo->save($data);
109
-    }
100
+	/**
101
+	 * Save the given model to the storage.
102
+	 *
103
+	 * @param  array $data
104
+	 * @return mixed
105
+	 */
106
+	public function save(array $data)
107
+	{
108
+		return $this->repo->save($data);
109
+	}
110 110
 
111
-    /**
112
-     * Delete record from the storage based on the given
113
-     * condition.
114
-     *
115
-     * @param  var $value condition value
116
-     * @param  string $attribute condition column name
117
-     * @return void
118
-     */
119
-    public function delete($value, $attribute = 'id')
120
-    {
121
-        return $this->repo->delete($value, $attribute);
122
-    }
111
+	/**
112
+	 * Delete record from the storage based on the given
113
+	 * condition.
114
+	 *
115
+	 * @param  var $value condition value
116
+	 * @param  string $attribute condition column name
117
+	 * @return void
118
+	 */
119
+	public function delete($value, $attribute = 'id')
120
+	{
121
+		return $this->repo->delete($value, $attribute);
122
+	}
123 123
     
124
-    /**
125
-     * Fetch records from the storage based on the given
126
-     * id.
127
-     *
128
-     * @param  integer $id
129
-     * @param  array   $relations
130
-     * @param  array   $columns
131
-     * @return object
132
-     */
133
-    public function find($id, $relations = [], $columns = ['*'])
134
-    {
135
-        return $this->repo->find($id, $relations, $columns);
136
-    }
124
+	/**
125
+	 * Fetch records from the storage based on the given
126
+	 * id.
127
+	 *
128
+	 * @param  integer $id
129
+	 * @param  array   $relations
130
+	 * @param  array   $columns
131
+	 * @return object
132
+	 */
133
+	public function find($id, $relations = [], $columns = ['*'])
134
+	{
135
+		return $this->repo->find($id, $relations, $columns);
136
+	}
137 137
     
138
-    /**
139
-     * Fetch records from the storage based on the given
140
-     * condition.
141
-     *
142
-     * @param  array   $conditions array of conditions
143
-     * @param  array   $relations
144
-     * @param  string  $sortBy
145
-     * @param  boolean $desc
146
-     * @param  array   $columns
147
-     * @return collection
148
-     */
149
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
150
-    {
151
-        return $this->repo->findBy($conditions, $relations, $sortBy, $desc, $columns);
152
-    }
138
+	/**
139
+	 * Fetch records from the storage based on the given
140
+	 * condition.
141
+	 *
142
+	 * @param  array   $conditions array of conditions
143
+	 * @param  array   $relations
144
+	 * @param  string  $sortBy
145
+	 * @param  boolean $desc
146
+	 * @param  array   $columns
147
+	 * @return collection
148
+	 */
149
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
150
+	{
151
+		return $this->repo->findBy($conditions, $relations, $sortBy, $desc, $columns);
152
+	}
153 153
 
154
-    /**
155
-     * Fetch the first record from the storage based on the given
156
-     * condition.
157
-     *
158
-     * @param  array   $conditions array of conditions
159
-     * @param  array   $relations
160
-     * @param  array   $columns
161
-     * @return object
162
-     */
163
-    public function first($conditions, $relations = [], $columns = ['*'])
164
-    {
165
-        return $this->repo->first($conditions, $relations, $columns);
166
-    }
154
+	/**
155
+	 * Fetch the first record from the storage based on the given
156
+	 * condition.
157
+	 *
158
+	 * @param  array   $conditions array of conditions
159
+	 * @param  array   $relations
160
+	 * @param  array   $columns
161
+	 * @return object
162
+	 */
163
+	public function first($conditions, $relations = [], $columns = ['*'])
164
+	{
165
+		return $this->repo->first($conditions, $relations, $columns);
166
+	}
167 167
 
168
-    /**
169
-     * Return the deleted models in pages based on the given conditions.
170
-     *
171
-     * @param  array   $conditions array of conditions
172
-     * @param  integer $perPage
173
-     * @param  string  $sortBy
174
-     * @param  boolean $desc
175
-     * @param  array   $columns
176
-     * @return collection
177
-     */
178
-    public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
179
-    {
180
-        return $this->repo->deleted($conditions, $perPage, $sortBy, $desc, $columns);
181
-    }
168
+	/**
169
+	 * Return the deleted models in pages based on the given conditions.
170
+	 *
171
+	 * @param  array   $conditions array of conditions
172
+	 * @param  integer $perPage
173
+	 * @param  string  $sortBy
174
+	 * @param  boolean $desc
175
+	 * @param  array   $columns
176
+	 * @return collection
177
+	 */
178
+	public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
179
+	{
180
+		return $this->repo->deleted($conditions, $perPage, $sortBy, $desc, $columns);
181
+	}
182 182
 
183
-    /**
184
-     * Restore the deleted model.
185
-     *
186
-     * @param  integer $id
187
-     * @return void
188
-     */
189
-    public function restore($id)
190
-    {
191
-        return $this->repo->restore($id);
192
-    }
183
+	/**
184
+	 * Restore the deleted model.
185
+	 *
186
+	 * @param  integer $id
187
+	 * @return void
188
+	 */
189
+	public function restore($id)
190
+	{
191
+		return $this->repo->restore($id);
192
+	}
193 193
 
194
-    /**
195
-     * Prepare filters for repo.
196
-     *
197
-     * @param  array   $conditions
198
-     * @return array
199
-     */
200
-    public function constructFilters($conditions)
201
-    {
202
-        $filters = [];
203
-        $translatable = $this->repo->model->translatable ?? [];
204
-        foreach ($conditions as $key => $value) {
205
-            if ((in_array($key, $this->repo->model->fillable ?? []) || method_exists($this->repo->model, $key) || in_array($key, ['or', 'and'])) && $key !== 'trashed') {
206
-                /**
207
-                 * Prepare key based on the the requested lang if it was translatable.
208
-                 */
209
-                $key = in_array($key, $translatable) ? $key . '->' . (Session::get('locale') == 'all' ? 'en' : Session::get('locale')) : $key;
194
+	/**
195
+	 * Prepare filters for repo.
196
+	 *
197
+	 * @param  array   $conditions
198
+	 * @return array
199
+	 */
200
+	public function constructFilters($conditions)
201
+	{
202
+		$filters = [];
203
+		$translatable = $this->repo->model->translatable ?? [];
204
+		foreach ($conditions as $key => $value) {
205
+			if ((in_array($key, $this->repo->model->fillable ?? []) || method_exists($this->repo->model, $key) || in_array($key, ['or', 'and'])) && $key !== 'trashed') {
206
+				/**
207
+				 * Prepare key based on the the requested lang if it was translatable.
208
+				 */
209
+				$key = in_array($key, $translatable) ? $key . '->' . (Session::get('locale') == 'all' ? 'en' : Session::get('locale')) : $key;
210 210
 
211
-                /**
212
-                 * Convert 0/1 or true/false to boolean in case of not foreign key.
213
-                 */
214
-                if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) {
215
-                    $filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
211
+				/**
212
+				 * Convert 0/1 or true/false to boolean in case of not foreign key.
213
+				 */
214
+				if (filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null && strpos($key, '_id') === false && ! is_null($value)) {
215
+					$filters[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
216 216
 
217
-                /**
218
-                 * Use in operator in case of foreign and comma seperated values.
219
-                 */
220
-                } elseif (! is_array($value) && strpos($key, '_id') && $value) {
221
-                    $filters[$key] = [
222
-                        'op' => 'in',
223
-                        'val' => explode(',', $value)
224
-                    ];
217
+				/**
218
+				 * Use in operator in case of foreign and comma seperated values.
219
+				 */
220
+				} elseif (! is_array($value) && strpos($key, '_id') && $value) {
221
+					$filters[$key] = [
222
+						'op' => 'in',
223
+						'val' => explode(',', $value)
224
+					];
225 225
 
226
-                /**
227
-                 * Use null operator in case of 0 value and foreign.
228
-                 */
229
-                } elseif (strpos($key, '_id') && $value == 0) {
230
-                    $filters[$key] = [
231
-                        'op' => 'null'
232
-                    ];
226
+				/**
227
+				 * Use null operator in case of 0 value and foreign.
228
+				 */
229
+				} elseif (strpos($key, '_id') && $value == 0) {
230
+					$filters[$key] = [
231
+						'op' => 'null'
232
+					];
233 233
 
234
-                /**
235
-                 * Consider values as a sub conditions if it is array.
236
-                 */
237
-                } elseif (is_array($value)) {
238
-                    $filters[$key] = $value;
234
+				/**
235
+				 * Consider values as a sub conditions if it is array.
236
+				 */
237
+				} elseif (is_array($value)) {
238
+					$filters[$key] = $value;
239 239
 
240
-                /**
241
-                 * Default string filteration.
242
-                 */
243
-                } elseif ($value) {
244
-                    $key = 'LOWER(' . $key . ')';
245
-                    $value = strtolower($value);
246
-                    $filters[$key] = [
247
-                        'op' => 'like',
248
-                        'val' => '%' . $value . '%'
249
-                    ];
250
-                }
251
-            }
252
-        }
240
+				/**
241
+				 * Default string filteration.
242
+				 */
243
+				} elseif ($value) {
244
+					$key = 'LOWER(' . $key . ')';
245
+					$value = strtolower($value);
246
+					$filters[$key] = [
247
+						'op' => 'like',
248
+						'val' => '%' . $value . '%'
249
+					];
250
+				}
251
+			}
252
+		}
253 253
 
254
-        return $filters;
255
-    }
254
+		return $filters;
255
+	}
256 256
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $translatable = $this->repo->model->translatable ?? [];
40 40
         $filters = $this->constructFilters($conditions);
41
-        $sortBy = in_array($sortBy, $translatable) ? $sortBy . '->' . Session::get('locale') : $sortBy;
41
+        $sortBy = in_array($sortBy, $translatable) ? $sortBy.'->'.Session::get('locale') : $sortBy;
42 42
 
43 43
         if ($trashed) {
44 44
             return $this->deleted(['and' => $filters], $perPage ?? 15, $sortBy ?? 'created_at', $desc ?? true);
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
                 /**
207 207
                  * Prepare key based on the the requested lang if it was translatable.
208 208
                  */
209
-                $key = in_array($key, $translatable) ? $key . '->' . (Session::get('locale') == 'all' ? 'en' : Session::get('locale')) : $key;
209
+                $key = in_array($key, $translatable) ? $key.'->'.(Session::get('locale') == 'all' ? 'en' : Session::get('locale')) : $key;
210 210
 
211 211
                 /**
212 212
                  * Convert 0/1 or true/false to boolean in case of not foreign key.
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
                 /**
218 218
                  * Use in operator in case of foreign and comma seperated values.
219 219
                  */
220
-                } elseif (! is_array($value) && strpos($key, '_id') && $value) {
220
+                } elseif ( ! is_array($value) && strpos($key, '_id') && $value) {
221 221
                     $filters[$key] = [
222 222
                         'op' => 'in',
223 223
                         'val' => explode(',', $value)
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
                  * Default string filteration.
242 242
                  */
243 243
                 } elseif ($value) {
244
-                    $key = 'LOWER(' . $key . ')';
244
+                    $key = 'LOWER('.$key.')';
245 245
                     $value = strtolower($value);
246 246
                     $filters[$key] = [
247 247
                         'op' => 'like',
248
-                        'val' => '%' . $value . '%'
248
+                        'val' => '%'.$value.'%'
249 249
                     ];
250 250
                 }
251 251
             }
Please login to merge, or discard this patch.
src/Modules/Core/BaseClasses/BaseRepository.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function __construct($model)
23 23
     {
24
-        $this->model  = $model;
24
+        $this->model = $model;
25 25
     }
26 26
 
27 27
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     public function count($conditions = false)
84 84
     {
85
-        if($conditions) {
85
+        if ($conditions) {
86 86
             $conditions = $this->constructConditions($conditions, $this->model);
87 87
             return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->count();
88 88
         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $model      = false;
117 117
         $relations  = [];
118 118
 
119
-        \DB::transaction(function () use (&$model, &$relations, $data) {
119
+        \DB::transaction(function() use (&$model, &$relations, $data) {
120 120
             
121 121
             $model     = $this->prepareModel($data);
122 122
             $relations = $this->prepareRelations($data, $model);
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public function delete($value, $attribute = 'id')
154 154
     {
155
-        \DB::transaction(function () use ($value, $attribute) {
156
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
155
+        \DB::transaction(function() use ($value, $attribute) {
156
+            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function($model) {
157 157
                 $model->delete();
158 158
             });
159 159
         });
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     {
244 244
         $model = $this->model->onlyTrashed()->find($id);
245 245
 
246
-        if (! $model) {
246
+        if ( ! $model) {
247 247
             \Errors::notFound(class_basename($this->model).' with id : '.$id);
248 248
         }
249 249
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
          * @var array
268 268
          */
269 269
         $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
270
-        if (! $model) {
270
+        if ( ! $model) {
271 271
             \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
272 272
         }
273 273
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
                      * If the relation has no value then marke the relation data
325 325
                      * related to the model to be deleted.
326 326
                      */
327
-                    if (! $value || ! count($value)) {
327
+                    if ( ! $value || ! count($value)) {
328 328
                         $relations[$relation] = 'delete';
329 329
                     }
330 330
                 }
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
                          * Check if the relation is a collection.
343 343
                          */
344 344
                         if (class_basename($model->$relation) == 'Collection') {
345
-                            if (! is_array($val)) {
345
+                            if ( ! is_array($val)) {
346 346
                                 $relationModel = $relationBaseModel->lockForUpdate()->find($val);
347 347
                             } else {
348 348
                                 /**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
                             /**
356 356
                              * If model doesn't exists.
357 357
                              */
358
-                            if (! $relationModel) {
358
+                            if ( ! $relationModel) {
359 359
                                 \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
360 360
                             }
361 361
 
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                                 /**
394 394
                                  * If model doesn't exists.
395 395
                                  */
396
-                                if (! $relationModel) {
396
+                                if ( ! $relationModel) {
397 397
                                     \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
398 398
                                 }
399 399
 
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
                 } elseif (strtolower($operator) == 'has') {
580 580
                     $sql              = $model->withTrashed()->withoutGlobalScopes()->has($key)->toSql();
581 581
                     $bindings         = $model->withTrashed()->withoutGlobalScopes()->has($key)->getBindings();
582
-                    if($value) {
582
+                    if ($value) {
583 583
                         $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
584 584
                         $conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
585 585
                         $conditionValues  = array_merge($conditionValues, $bindings);
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
         $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
611 611
         $path       = explode('->', $value);
612 612
         $field      = array_shift($path);
613
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
613
+        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function($part) {
614 614
             return '"'.$part.'"';
615 615
         })->implode('.'));
616 616
         
Please login to merge, or discard this patch.
Indentation   +664 added lines, -664 removed lines patch added patch discarded remove patch
@@ -8,681 +8,681 @@
 block discarded – undo
8 8
 
9 9
 abstract class BaseRepository implements BaseRepositoryInterface
10 10
 {
11
-    /**
12
-     * @var object
13
-     */
14
-    public $model;
11
+	/**
12
+	 * @var object
13
+	 */
14
+	public $model;
15 15
     
16
-    /**
17
-     * Init new object.
18
-     *
19
-     * @var mixed model
20
-     * @return  void
21
-     */
22
-    public function __construct($model)
23
-    {
24
-        $this->model  = $model;
25
-    }
26
-
27
-    /**
28
-     * Fetch all records with relations from the storage.
29
-     *
30
-     * @param  array   $relations
31
-     * @param  string  $sortBy
32
-     * @param  boolean $desc
33
-     * @param  array   $columns
34
-     * @return collection
35
-     */
36
-    public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
37
-    {
38
-        $sort = $desc ? 'desc' : 'asc';
39
-        return $this->model->with($relations)->orderBy($sortBy, $sort)->get($columns);
40
-    }
16
+	/**
17
+	 * Init new object.
18
+	 *
19
+	 * @var mixed model
20
+	 * @return  void
21
+	 */
22
+	public function __construct($model)
23
+	{
24
+		$this->model  = $model;
25
+	}
26
+
27
+	/**
28
+	 * Fetch all records with relations from the storage.
29
+	 *
30
+	 * @param  array   $relations
31
+	 * @param  string  $sortBy
32
+	 * @param  boolean $desc
33
+	 * @param  array   $columns
34
+	 * @return collection
35
+	 */
36
+	public function all($relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
37
+	{
38
+		$sort = $desc ? 'desc' : 'asc';
39
+		return $this->model->with($relations)->orderBy($sortBy, $sort)->get($columns);
40
+	}
41 41
     
42
-    /**
43
-     * Fetch all records with relations from storage in pages.
44
-     *
45
-     * @param  integer $perPage
46
-     * @param  array   $relations
47
-     * @param  string  $sortBy
48
-     * @param  boolean $desc
49
-     * @param  array   $columns
50
-     * @return collection
51
-     */
52
-    public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
53
-    {
54
-        $sort = $desc ? 'desc' : 'asc';
55
-        return $this->model->with($relations)->orderBy($sortBy, $sort)->paginate($perPage, $columns);
56
-    }
57
-
58
-    /**
59
-     * Fetch all records with relations based on
60
-     * the given condition from storage in pages.
61
-     *
62
-     * @param  array   $conditions array of conditions
63
-     * @param  integer $perPage
64
-     * @param  array   $relations
65
-     * @param  string  $sortBy
66
-     * @param  boolean $desc
67
-     * @param  array   $columns
68
-     * @return collection
69
-     */
70
-    public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
71
-    {
72
-        $conditions = $this->constructConditions($conditions, $this->model);
73
-        $sort       = $desc ? 'desc' : 'asc';
74
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
75
-    }
76
-
77
-    /**
78
-     * Count all records based on the given condition from storage.
79
-     *
80
-     * @param  array   $conditions array of conditions
81
-     * @return collection
82
-     */
83
-    public function count($conditions = false)
84
-    {
85
-        if($conditions) {
86
-            $conditions = $this->constructConditions($conditions, $this->model);
87
-            return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->count();
88
-        }
42
+	/**
43
+	 * Fetch all records with relations from storage in pages.
44
+	 *
45
+	 * @param  integer $perPage
46
+	 * @param  array   $relations
47
+	 * @param  string  $sortBy
48
+	 * @param  boolean $desc
49
+	 * @param  array   $columns
50
+	 * @return collection
51
+	 */
52
+	public function paginate($perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
53
+	{
54
+		$sort = $desc ? 'desc' : 'asc';
55
+		return $this->model->with($relations)->orderBy($sortBy, $sort)->paginate($perPage, $columns);
56
+	}
57
+
58
+	/**
59
+	 * Fetch all records with relations based on
60
+	 * the given condition from storage in pages.
61
+	 *
62
+	 * @param  array   $conditions array of conditions
63
+	 * @param  integer $perPage
64
+	 * @param  array   $relations
65
+	 * @param  string  $sortBy
66
+	 * @param  boolean $desc
67
+	 * @param  array   $columns
68
+	 * @return collection
69
+	 */
70
+	public function paginateBy($conditions, $perPage = 15, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
71
+	{
72
+		$conditions = $this->constructConditions($conditions, $this->model);
73
+		$sort       = $desc ? 'desc' : 'asc';
74
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage, $columns);
75
+	}
76
+
77
+	/**
78
+	 * Count all records based on the given condition from storage.
79
+	 *
80
+	 * @param  array   $conditions array of conditions
81
+	 * @return collection
82
+	 */
83
+	public function count($conditions = false)
84
+	{
85
+		if($conditions) {
86
+			$conditions = $this->constructConditions($conditions, $this->model);
87
+			return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->count();
88
+		}
89 89
         
90
-        return $this->model->count();
91
-    }
92
-
93
-    /**
94
-     * Return max value for the given column.
95
-     *
96
-     * @param  column
97
-     * @return integer
98
-     */
99
-    public function max($column)
100
-    {
101
-        return $this->model->max($column);
102
-    }
103
-
104
-    /**
105
-     * Pluck column based on the given condition from storage.
106
-     *
107
-     * @param  array   $conditions array of conditions
108
-     * @param  string   $column
109
-     * @return collection
110
-     */
111
-    public function pluck($conditions, $column)
112
-    {
113
-        $conditions = $this->constructConditions($conditions, $this->model);
114
-        return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->pluck($column);
115
-    }
116
-
117
-    /**
118
-     * Update the given data based on the given conditions.
119
-     *
120
-     * @param  array   $conditions array of conditions
121
-     * @param  array   $data
122
-     * @return collection
123
-     */
124
-    public function update($conditions, $data)
125
-    {
126
-        $conditions = $this->constructConditions($conditions, $this->model);
127
-        return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->update($data);
128
-    }
90
+		return $this->model->count();
91
+	}
92
+
93
+	/**
94
+	 * Return max value for the given column.
95
+	 *
96
+	 * @param  column
97
+	 * @return integer
98
+	 */
99
+	public function max($column)
100
+	{
101
+		return $this->model->max($column);
102
+	}
103
+
104
+	/**
105
+	 * Pluck column based on the given condition from storage.
106
+	 *
107
+	 * @param  array   $conditions array of conditions
108
+	 * @param  string   $column
109
+	 * @return collection
110
+	 */
111
+	public function pluck($conditions, $column)
112
+	{
113
+		$conditions = $this->constructConditions($conditions, $this->model);
114
+		return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->pluck($column);
115
+	}
116
+
117
+	/**
118
+	 * Update the given data based on the given conditions.
119
+	 *
120
+	 * @param  array   $conditions array of conditions
121
+	 * @param  array   $data
122
+	 * @return collection
123
+	 */
124
+	public function update($conditions, $data)
125
+	{
126
+		$conditions = $this->constructConditions($conditions, $this->model);
127
+		return $this->model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->update($data);
128
+	}
129 129
     
130
-    /**
131
-     * Save the given model to the storage.
132
-     *
133
-     * @param  array $data
134
-     * @return mixed
135
-     */
136
-    public function save(array $data)
137
-    {
138
-        $local = \Session::get('locale');
139
-        \Session::put('locale', 'all');
140
-        $model      = false;
141
-        $relations  = [];
142
-
143
-        \DB::transaction(function () use (&$model, &$relations, $data) {
130
+	/**
131
+	 * Save the given model to the storage.
132
+	 *
133
+	 * @param  array $data
134
+	 * @return mixed
135
+	 */
136
+	public function save(array $data)
137
+	{
138
+		$local = \Session::get('locale');
139
+		\Session::put('locale', 'all');
140
+		$model      = false;
141
+		$relations  = [];
142
+
143
+		\DB::transaction(function () use (&$model, &$relations, $data) {
144 144
             
145
-            $model     = $this->prepareModel($data);
146
-            $relations = $this->prepareRelations($data, $model);
147
-            $model     = $this->saveModel($model, $relations);
148
-        });
149
-        \Session::put('locale', $local);
145
+			$model     = $this->prepareModel($data);
146
+			$relations = $this->prepareRelations($data, $model);
147
+			$model     = $this->saveModel($model, $relations);
148
+		});
149
+		\Session::put('locale', $local);
150 150
         
151
-        if (count($relations)) {
152
-            $model->load(...array_keys($relations));
153
-        }
151
+		if (count($relations)) {
152
+			$model->load(...array_keys($relations));
153
+		}
154 154
 
155
-        return $model;
156
-    }
155
+		return $model;
156
+	}
157 157
     
158
-    /**
159
-     * Insert the given model/models to the storage.
160
-     *
161
-     * @param  array $data
162
-     * @return mixed
163
-     */
164
-    public function insert(array $data)
165
-    {
166
-        return $this->model->insert($data);
167
-    }
168
-
169
-    /**
170
-     * Delete record from the storage based on the given
171
-     * condition.
172
-     *
173
-     * @param  var $value condition value
174
-     * @param  string $attribute condition column name
175
-     * @return void
176
-     */
177
-    public function delete($value, $attribute = 'id')
178
-    {
179
-        \DB::transaction(function () use ($value, $attribute) {
180
-            $this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
181
-                $model->delete();
182
-            });
183
-        });
184
-    }
158
+	/**
159
+	 * Insert the given model/models to the storage.
160
+	 *
161
+	 * @param  array $data
162
+	 * @return mixed
163
+	 */
164
+	public function insert(array $data)
165
+	{
166
+		return $this->model->insert($data);
167
+	}
168
+
169
+	/**
170
+	 * Delete record from the storage based on the given
171
+	 * condition.
172
+	 *
173
+	 * @param  var $value condition value
174
+	 * @param  string $attribute condition column name
175
+	 * @return void
176
+	 */
177
+	public function delete($value, $attribute = 'id')
178
+	{
179
+		\DB::transaction(function () use ($value, $attribute) {
180
+			$this->model->where($attribute, '=', $value)->lockForUpdate()->get()->each(function ($model) {
181
+				$model->delete();
182
+			});
183
+		});
184
+	}
185 185
     
186
-    /**
187
-     * Fetch records from the storage based on the given
188
-     * id.
189
-     *
190
-     * @param  integer $id
191
-     * @param  string[]   $relations
192
-     * @param  array   $columns
193
-     * @return object
194
-     */
195
-    public function find($id, $relations = [], $columns = ['*'])
196
-    {
197
-        return $this->model->with($relations)->find($id, $columns);
198
-    }
186
+	/**
187
+	 * Fetch records from the storage based on the given
188
+	 * id.
189
+	 *
190
+	 * @param  integer $id
191
+	 * @param  string[]   $relations
192
+	 * @param  array   $columns
193
+	 * @return object
194
+	 */
195
+	public function find($id, $relations = [], $columns = ['*'])
196
+	{
197
+		return $this->model->with($relations)->find($id, $columns);
198
+	}
199 199
     
200
-    /**
201
-     * Fetch records from the storage based on the given
202
-     * condition.
203
-     *
204
-     * @param  array   $conditions array of conditions
205
-     * @param  array   $relations
206
-     * @param  string  $sortBy
207
-     * @param  boolean $desc
208
-     * @param  array   $columns
209
-     * @return collection
210
-     */
211
-    public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
212
-    {
213
-        $conditions = $this->constructConditions($conditions, $this->model);
214
-        $sort       = $desc ? 'desc' : 'asc';
215
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
216
-    }
217
-
218
-    /**
219
-     * Fetch the first record from the storage based on the given
220
-     * condition.
221
-     *
222
-     * @param  array   $conditions array of conditions
223
-     * @param  array   $relations
224
-     * @param  array   $columns
225
-     * @return object
226
-     */
227
-    public function first($conditions, $relations = [], $columns = ['*'])
228
-    {
229
-        $conditions = $this->constructConditions($conditions, $this->model);
230
-        return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
231
-    }
232
-
233
-    /**
234
-     * Return the deleted models in pages based on the given conditions.
235
-     *
236
-     * @param  array   $conditions array of conditions
237
-     * @param  integer $perPage
238
-     * @param  string  $sortBy
239
-     * @param  boolean $desc
240
-     * @param  array   $columns
241
-     * @return collection
242
-     */
243
-    public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
244
-    {
245
-        unset($conditions['page']);
246
-        unset($conditions['perPage']);
247
-        unset($conditions['sortBy']);
248
-        unset($conditions['sort']);
249
-        $conditions = $this->constructConditions($conditions, $this->model);
250
-        $sort       = $desc ? 'desc' : 'asc';
251
-        $model      = $this->model->onlyTrashed();
252
-
253
-        if (count($conditions['conditionValues'])) {
254
-            $model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
255
-        }
256
-
257
-        return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
258
-    }
259
-
260
-    /**
261
-     * Restore the deleted model.
262
-     *
263
-     * @param  integer $id
264
-     * @return void
265
-     */
266
-    public function restore($id)
267
-    {
268
-        $model = $this->model->onlyTrashed()->find($id);
269
-
270
-        if (! $model) {
271
-            \Errors::notFound(class_basename($this->model).' with id : '.$id);
272
-        }
273
-
274
-        $model->restore();
275
-    }
276
-
277
-    /**
278
-     * Fill the model with the given data.
279
-     *
280
-     * @param   array  $data
281
-     *
282
-     * @return  object
283
-     */
284
-    public function prepareModel($data)
285
-    {
286
-        $modelClass = $this->model;
287
-
288
-        /**
289
-         * If the id is present in the data then select the model for updating,
290
-         * else create new model.
291
-         * @var array
292
-         */
293
-        $model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
294
-        if (! $model) {
295
-            \Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
296
-        }
297
-
298
-        /**
299
-         * Construct the model object with the given data,
300
-         * and if there is a relation add it to relations array,
301
-         * then save the model.
302
-         */
303
-        foreach ($data as $key => $value) {
304
-            if (array_search($key, $model->getFillable(), true) !== false) {
305
-                /**
306
-                 * If the attribute isn't a relation and prevent attributes not in the fillable.
307
-                 */
308
-                $model->$key = $value;
309
-            }
310
-        }
311
-
312
-        return $model;
313
-    }
200
+	/**
201
+	 * Fetch records from the storage based on the given
202
+	 * condition.
203
+	 *
204
+	 * @param  array   $conditions array of conditions
205
+	 * @param  array   $relations
206
+	 * @param  string  $sortBy
207
+	 * @param  boolean $desc
208
+	 * @param  array   $columns
209
+	 * @return collection
210
+	 */
211
+	public function findBy($conditions, $relations = [], $sortBy = 'created_at', $desc = 1, $columns = ['*'])
212
+	{
213
+		$conditions = $this->constructConditions($conditions, $this->model);
214
+		$sort       = $desc ? 'desc' : 'asc';
215
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->get($columns);
216
+	}
217
+
218
+	/**
219
+	 * Fetch the first record from the storage based on the given
220
+	 * condition.
221
+	 *
222
+	 * @param  array   $conditions array of conditions
223
+	 * @param  array   $relations
224
+	 * @param  array   $columns
225
+	 * @return object
226
+	 */
227
+	public function first($conditions, $relations = [], $columns = ['*'])
228
+	{
229
+		$conditions = $this->constructConditions($conditions, $this->model);
230
+		return $this->model->with($relations)->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->first($columns);
231
+	}
232
+
233
+	/**
234
+	 * Return the deleted models in pages based on the given conditions.
235
+	 *
236
+	 * @param  array   $conditions array of conditions
237
+	 * @param  integer $perPage
238
+	 * @param  string  $sortBy
239
+	 * @param  boolean $desc
240
+	 * @param  array   $columns
241
+	 * @return collection
242
+	 */
243
+	public function deleted($conditions, $perPage = 15, $sortBy = 'created_at', $desc = 1, $columns = ['*'])
244
+	{
245
+		unset($conditions['page']);
246
+		unset($conditions['perPage']);
247
+		unset($conditions['sortBy']);
248
+		unset($conditions['sort']);
249
+		$conditions = $this->constructConditions($conditions, $this->model);
250
+		$sort       = $desc ? 'desc' : 'asc';
251
+		$model      = $this->model->onlyTrashed();
252
+
253
+		if (count($conditions['conditionValues'])) {
254
+			$model->whereRaw($conditions['conditionString'], $conditions['conditionValues']);
255
+		}
256
+
257
+		return $model->orderBy($sortBy, $sort)->paginate($perPage, $columns);
258
+	}
259
+
260
+	/**
261
+	 * Restore the deleted model.
262
+	 *
263
+	 * @param  integer $id
264
+	 * @return void
265
+	 */
266
+	public function restore($id)
267
+	{
268
+		$model = $this->model->onlyTrashed()->find($id);
269
+
270
+		if (! $model) {
271
+			\Errors::notFound(class_basename($this->model).' with id : '.$id);
272
+		}
273
+
274
+		$model->restore();
275
+	}
276
+
277
+	/**
278
+	 * Fill the model with the given data.
279
+	 *
280
+	 * @param   array  $data
281
+	 *
282
+	 * @return  object
283
+	 */
284
+	public function prepareModel($data)
285
+	{
286
+		$modelClass = $this->model;
287
+
288
+		/**
289
+		 * If the id is present in the data then select the model for updating,
290
+		 * else create new model.
291
+		 * @var array
292
+		 */
293
+		$model = Arr::has($data, 'id') ? $modelClass->lockForUpdate()->find($data['id']) : new $modelClass;
294
+		if (! $model) {
295
+			\Errors::notFound(class_basename($modelClass).' with id : '.$data['id']);
296
+		}
297
+
298
+		/**
299
+		 * Construct the model object with the given data,
300
+		 * and if there is a relation add it to relations array,
301
+		 * then save the model.
302
+		 */
303
+		foreach ($data as $key => $value) {
304
+			if (array_search($key, $model->getFillable(), true) !== false) {
305
+				/**
306
+				 * If the attribute isn't a relation and prevent attributes not in the fillable.
307
+				 */
308
+				$model->$key = $value;
309
+			}
310
+		}
311
+
312
+		return $model;
313
+	}
314 314
     
315
-    /**
316
-     * Prepare related models based on the given data for the given model.
317
-     *
318
-     * @param   array  $data
319
-     * @param   object $model
320
-     *
321
-     * @return  array
322
-     */
323
-    public function prepareRelations($data, $model)
324
-    {
325
-        /**
326
-         * Init the relation array
327
-         *
328
-         * @var array
329
-         */
330
-        $relations = [];
331
-
332
-        /**
333
-         * Construct the model object with the given data,
334
-         * and if there is a relation add it to relations array,
335
-         * then save the model.
336
-         */
337
-        foreach ($data as $key => $value) {
338
-            /**
339
-             * If the attribute is a relation.
340
-             */
341
-            $relation = \Str::camel($key);
342
-            if (method_exists($model, $relation) && \Core::$relation()) {
343
-                /**
344
-                 * Check if the relation is a collection.
345
-                 */
346
-                if (class_basename($model->$relation) == 'Collection') {
347
-                    /**
348
-                     * If the relation has no value then marke the relation data
349
-                     * related to the model to be deleted.
350
-                     */
351
-                    if (! $value || ! count($value)) {
352
-                        $relations[$relation] = 'delete';
353
-                    }
354
-                }
355
-                if (is_array($value)) {
356
-                    /**
357
-                     * Loop through the relation data.
358
-                     */
359
-                    foreach ($value as $attr => $val) {
360
-                        /**
361
-                         * Get the relation model.
362
-                         */
363
-                        $relationBaseModel = \Core::$relation()->model;
364
-
365
-                        /**
366
-                         * Check if the relation is a collection.
367
-                         */
368
-                        if (class_basename($model->$relation) == 'Collection') {
369
-                            if (! is_array($val)) {
370
-                                $relationModel = $relationBaseModel->lockForUpdate()->find($val);
371
-                            } else {
372
-                                /**
373
-                                 * If the id is present in the data then select the relation model for updating,
374
-                                 * else create new model.
375
-                                 */
376
-                                $relationModel = Arr::has($val, 'id') ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
377
-                            }
378
-
379
-                            /**
380
-                             * If model doesn't exists.
381
-                             */
382
-                            if (! $relationModel) {
383
-                                \Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
384
-                            }
385
-
386
-                            if (is_array($val)) {
387
-                                /**
388
-                                 * Loop through the relation attributes.
389
-                                 */
390
-                                foreach ($val as $attr => $val) {
391
-                                    /**
392
-                                     * Prevent the sub relations or attributes not in the fillable.
393
-                                     */
394
-                                    if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false && class_basename($model->$key()) !== 'BelongsToMany') {
395
-                                        $relationModel->$attr = $val;
396
-                                    } elseif (gettype($val) !== 'object' && gettype($val) !== 'array' && $attr !== 'id') {
397
-                                        $extra[$attr] = $val;
398
-                                    }
399
-                                }
400
-                            }
401
-
402
-                            if (isset($extra)) {
403
-                                $relationModel->extra = $extra;
404
-                            }
405
-                            $relations[$relation][] = $relationModel;
406
-                        } else {
407
-                            /**
408
-                             * Prevent the sub relations.
409
-                             */
410
-                            if (gettype($val) !== 'object' && gettype($val) !== 'array') {
411
-                                /**
412
-                                 * If the id is present in the data then select the relation model for updating,
413
-                                 * else create new model.
414
-                                 */
415
-                                $relationModel = Arr::has($value, 'id') ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
416
-
417
-                                /**
418
-                                 * If model doesn't exists.
419
-                                 */
420
-                                if (! $relationModel) {
421
-                                    \Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
422
-                                }
423
-
424
-                                foreach ($value as $relationAttribute => $relationValue) {
425
-                                    /**
426
-                                     * Prevent attributes not in the fillable.
427
-                                     */
428
-                                    if (array_search($relationAttribute, $relationModel->getFillable(), true) !== false) {
429
-                                        $relationModel->$relationAttribute = $relationValue;
430
-                                    }
431
-                                }
432
-
433
-                                $relations[$relation] = $relationModel;
434
-                            }
435
-                        }
436
-                    }
437
-                }
438
-            }
439
-        }
440
-
441
-        return $relations;
442
-    }
443
-
444
-    /**
445
-     * Save the model with related models.
446
-     *
447
-     * @param   object  $model
448
-     * @param   array   $relations
449
-     *
450
-     * @return  object
451
-     */
452
-    public function saveModel($model, $relations)
453
-    {
454
-        /**
455
-         * Sort relations.
456
-         */
457
-        $belongsTo = [];
458
-        $hasOne = [];
459
-        $array = [];
460
-        foreach ($relations as $key => $value) {
461
-            if (class_basename($model->$key()) === 'BelongsTo') {
462
-                $belongsTo[$key] = $value;
463
-            } elseif (class_basename($model->$key()) === 'HasOne') {
464
-                $hasOne[$key] = $value;
465
-            } else {
466
-                $array[$key] = $value;
467
-            }
468
-        };
469
-
470
-        $relations = array_merge($belongsTo, $hasOne, $array);
471
-
472
-        /**
473
-         * Loop through the relations array.
474
-         */
475
-        foreach ($relations as $key => $value) {
476
-            /**
477
-             * If the relation is marked for delete then delete it.
478
-             */
479
-            if ($value == 'delete' && $model->$key()->count()) {
480
-                switch (class_basename($model->$key())) {
481
-                    /**
482
-                     * If the relation is one to many then delete all
483
-                     * relations who's id isn't in the ids array.
484
-                     */
485
-                    case 'HasMany':
486
-                        $model->$key()->delete();
487
-                        break;
488
-
489
-                    /**
490
-                     * If the relation is many to many then
491
-                     * detach the previous data and attach
492
-                     * the ids array to the model.
493
-                     */
494
-                    case 'BelongsToMany':
495
-                        $model->$key()->detach();
496
-                        break;
497
-                }
498
-            } elseif (gettype($value) == 'array') {
499
-                /**
500
-                 * Save the model.
501
-                 */
502
-                $model->save();
503
-                $ids = [];
504
-
505
-                /**
506
-                 * Loop through the relations.
507
-                 */
508
-                foreach ($value as $val) {
509
-                    switch (class_basename($model->$key())) {
510
-                        /**
511
-                         * If the relation is one to many then update it's foreign key with
512
-                         * the model id and save it then add its id to ids array to delete all
513
-                         * relations who's id isn't in the ids array.
514
-                         */
515
-                        case 'HasMany':
516
-                            $foreignKeyName       = $model->$key()->getForeignKeyName();
517
-                            $val->$foreignKeyName = $model->id;
518
-                            $val->save();
519
-                            $ids[] = $val->id;
520
-                            break;
521
-
522
-                        /**
523
-                         * If the relation is many to many then add it's id to the ids array to
524
-                         * attache these ids to the model.
525
-                         */
526
-                        case 'BelongsToMany':
527
-                        case 'MorphToMany':
528
-                            $extra = $val->extra;
529
-                            unset($val->extra);
530
-                            $val->save();
531
-                            $ids[$val->id] = $extra ?? [];
532
-                            break;
533
-                    }
534
-                }
535
-                switch (class_basename($model->$key())) {
536
-                    /**
537
-                     * If the relation is one to many then delete all
538
-                     * relations who's id isn't in the ids array.
539
-                     */
540
-                    case 'HasMany':
541
-                        $model->$key()->whereNotIn('id', $ids)->delete();
542
-                        break;
543
-
544
-                    /**
545
-                     * If the relation is many to many then
546
-                     * detach the previous data and attach
547
-                     * the ids array to the model.
548
-                     */
549
-                    case 'BelongsToMany':
550
-                    case 'MorphToMany':
551
-                        $model->$key()->detach();
552
-                        $model->$key()->attach($ids);
553
-                        break;
554
-                }
555
-            } else {
556
-                switch (class_basename($model->$key())) {
557
-                    /**
558
-                     * If the relation is one to one.
559
-                     */
560
-                    case 'HasOne':
561
-                        /**
562
-                         * Save the model.
563
-                         */
564
-                        $model->save();
565
-                        $foreignKeyName         = $model->$key()->getForeignKeyName();
566
-                        $value->$foreignKeyName = $model->id;
567
-                        $value->save();
568
-                        break;
569
-                    case 'BelongsTo':
570
-                        /**
571
-                         * Save the model.
572
-                         */
573
-                        $value->save();
574
-                        $model->$key()->associate($value);
575
-                        break;
576
-                }
577
-            }
578
-        }
579
-
580
-        /**
581
-         * Save the model.
582
-         */
583
-        $model->save();
584
-
585
-        return $model;
586
-    }
587
-
588
-    /**
589
-     * Build the conditions recursively for the retrieving methods.
590
-     * @param  array $conditions
591
-     * @return array
592
-     */
593
-    protected function constructConditions($conditions, $model)
594
-    {
595
-        $conditionString = '';
596
-        $conditionValues = [];
597
-        foreach ($conditions as $key => $value) {
598
-            if (Str::contains($key, '->')) {
599
-                $key = $this->wrapJsonSelector($key);
600
-            }
601
-
602
-            if ($key == 'and') {
603
-                $conditions       = $this->constructConditions($value, $model);
604
-                $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
605
-                $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
606
-            } elseif ($key == 'or') {
607
-                $conditions       = $this->constructConditions($value, $model);
608
-                $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
609
-                $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
610
-            } else {
611
-                if (is_array($value)) {
612
-                    $operator = $value['op'];
613
-                    if (strtolower($operator) == 'between') {
614
-                        $value1 = $value['val1'];
615
-                        $value2 = $value['val2'];
616
-                    } else {
617
-                        $value = Arr::get($value, 'val', '');
618
-                    }
619
-                } else {
620
-                    $operator = '=';
621
-                }
315
+	/**
316
+	 * Prepare related models based on the given data for the given model.
317
+	 *
318
+	 * @param   array  $data
319
+	 * @param   object $model
320
+	 *
321
+	 * @return  array
322
+	 */
323
+	public function prepareRelations($data, $model)
324
+	{
325
+		/**
326
+		 * Init the relation array
327
+		 *
328
+		 * @var array
329
+		 */
330
+		$relations = [];
331
+
332
+		/**
333
+		 * Construct the model object with the given data,
334
+		 * and if there is a relation add it to relations array,
335
+		 * then save the model.
336
+		 */
337
+		foreach ($data as $key => $value) {
338
+			/**
339
+			 * If the attribute is a relation.
340
+			 */
341
+			$relation = \Str::camel($key);
342
+			if (method_exists($model, $relation) && \Core::$relation()) {
343
+				/**
344
+				 * Check if the relation is a collection.
345
+				 */
346
+				if (class_basename($model->$relation) == 'Collection') {
347
+					/**
348
+					 * If the relation has no value then marke the relation data
349
+					 * related to the model to be deleted.
350
+					 */
351
+					if (! $value || ! count($value)) {
352
+						$relations[$relation] = 'delete';
353
+					}
354
+				}
355
+				if (is_array($value)) {
356
+					/**
357
+					 * Loop through the relation data.
358
+					 */
359
+					foreach ($value as $attr => $val) {
360
+						/**
361
+						 * Get the relation model.
362
+						 */
363
+						$relationBaseModel = \Core::$relation()->model;
364
+
365
+						/**
366
+						 * Check if the relation is a collection.
367
+						 */
368
+						if (class_basename($model->$relation) == 'Collection') {
369
+							if (! is_array($val)) {
370
+								$relationModel = $relationBaseModel->lockForUpdate()->find($val);
371
+							} else {
372
+								/**
373
+								 * If the id is present in the data then select the relation model for updating,
374
+								 * else create new model.
375
+								 */
376
+								$relationModel = Arr::has($val, 'id') ? $relationBaseModel->lockForUpdate()->find($val['id']) : new $relationBaseModel;
377
+							}
378
+
379
+							/**
380
+							 * If model doesn't exists.
381
+							 */
382
+							if (! $relationModel) {
383
+								\Errors::notFound(class_basename($relationBaseModel).' with id : '.$val['id']);
384
+							}
385
+
386
+							if (is_array($val)) {
387
+								/**
388
+								 * Loop through the relation attributes.
389
+								 */
390
+								foreach ($val as $attr => $val) {
391
+									/**
392
+									 * Prevent the sub relations or attributes not in the fillable.
393
+									 */
394
+									if (gettype($val) !== 'object' && gettype($val) !== 'array' && array_search($attr, $relationModel->getFillable(), true) !== false && class_basename($model->$key()) !== 'BelongsToMany') {
395
+										$relationModel->$attr = $val;
396
+									} elseif (gettype($val) !== 'object' && gettype($val) !== 'array' && $attr !== 'id') {
397
+										$extra[$attr] = $val;
398
+									}
399
+								}
400
+							}
401
+
402
+							if (isset($extra)) {
403
+								$relationModel->extra = $extra;
404
+							}
405
+							$relations[$relation][] = $relationModel;
406
+						} else {
407
+							/**
408
+							 * Prevent the sub relations.
409
+							 */
410
+							if (gettype($val) !== 'object' && gettype($val) !== 'array') {
411
+								/**
412
+								 * If the id is present in the data then select the relation model for updating,
413
+								 * else create new model.
414
+								 */
415
+								$relationModel = Arr::has($value, 'id') ? $relationBaseModel->lockForUpdate()->find($value['id']) : new $relationBaseModel;
416
+
417
+								/**
418
+								 * If model doesn't exists.
419
+								 */
420
+								if (! $relationModel) {
421
+									\Errors::notFound(class_basename($relationBaseModel).' with id : '.$value['id']);
422
+								}
423
+
424
+								foreach ($value as $relationAttribute => $relationValue) {
425
+									/**
426
+									 * Prevent attributes not in the fillable.
427
+									 */
428
+									if (array_search($relationAttribute, $relationModel->getFillable(), true) !== false) {
429
+										$relationModel->$relationAttribute = $relationValue;
430
+									}
431
+								}
432
+
433
+								$relations[$relation] = $relationModel;
434
+							}
435
+						}
436
+					}
437
+				}
438
+			}
439
+		}
440
+
441
+		return $relations;
442
+	}
443
+
444
+	/**
445
+	 * Save the model with related models.
446
+	 *
447
+	 * @param   object  $model
448
+	 * @param   array   $relations
449
+	 *
450
+	 * @return  object
451
+	 */
452
+	public function saveModel($model, $relations)
453
+	{
454
+		/**
455
+		 * Sort relations.
456
+		 */
457
+		$belongsTo = [];
458
+		$hasOne = [];
459
+		$array = [];
460
+		foreach ($relations as $key => $value) {
461
+			if (class_basename($model->$key()) === 'BelongsTo') {
462
+				$belongsTo[$key] = $value;
463
+			} elseif (class_basename($model->$key()) === 'HasOne') {
464
+				$hasOne[$key] = $value;
465
+			} else {
466
+				$array[$key] = $value;
467
+			}
468
+		};
469
+
470
+		$relations = array_merge($belongsTo, $hasOne, $array);
471
+
472
+		/**
473
+		 * Loop through the relations array.
474
+		 */
475
+		foreach ($relations as $key => $value) {
476
+			/**
477
+			 * If the relation is marked for delete then delete it.
478
+			 */
479
+			if ($value == 'delete' && $model->$key()->count()) {
480
+				switch (class_basename($model->$key())) {
481
+					/**
482
+					 * If the relation is one to many then delete all
483
+					 * relations who's id isn't in the ids array.
484
+					 */
485
+					case 'HasMany':
486
+						$model->$key()->delete();
487
+						break;
488
+
489
+					/**
490
+					 * If the relation is many to many then
491
+					 * detach the previous data and attach
492
+					 * the ids array to the model.
493
+					 */
494
+					case 'BelongsToMany':
495
+						$model->$key()->detach();
496
+						break;
497
+				}
498
+			} elseif (gettype($value) == 'array') {
499
+				/**
500
+				 * Save the model.
501
+				 */
502
+				$model->save();
503
+				$ids = [];
504
+
505
+				/**
506
+				 * Loop through the relations.
507
+				 */
508
+				foreach ($value as $val) {
509
+					switch (class_basename($model->$key())) {
510
+						/**
511
+						 * If the relation is one to many then update it's foreign key with
512
+						 * the model id and save it then add its id to ids array to delete all
513
+						 * relations who's id isn't in the ids array.
514
+						 */
515
+						case 'HasMany':
516
+							$foreignKeyName       = $model->$key()->getForeignKeyName();
517
+							$val->$foreignKeyName = $model->id;
518
+							$val->save();
519
+							$ids[] = $val->id;
520
+							break;
521
+
522
+						/**
523
+						 * If the relation is many to many then add it's id to the ids array to
524
+						 * attache these ids to the model.
525
+						 */
526
+						case 'BelongsToMany':
527
+						case 'MorphToMany':
528
+							$extra = $val->extra;
529
+							unset($val->extra);
530
+							$val->save();
531
+							$ids[$val->id] = $extra ?? [];
532
+							break;
533
+					}
534
+				}
535
+				switch (class_basename($model->$key())) {
536
+					/**
537
+					 * If the relation is one to many then delete all
538
+					 * relations who's id isn't in the ids array.
539
+					 */
540
+					case 'HasMany':
541
+						$model->$key()->whereNotIn('id', $ids)->delete();
542
+						break;
543
+
544
+					/**
545
+					 * If the relation is many to many then
546
+					 * detach the previous data and attach
547
+					 * the ids array to the model.
548
+					 */
549
+					case 'BelongsToMany':
550
+					case 'MorphToMany':
551
+						$model->$key()->detach();
552
+						$model->$key()->attach($ids);
553
+						break;
554
+				}
555
+			} else {
556
+				switch (class_basename($model->$key())) {
557
+					/**
558
+					 * If the relation is one to one.
559
+					 */
560
+					case 'HasOne':
561
+						/**
562
+						 * Save the model.
563
+						 */
564
+						$model->save();
565
+						$foreignKeyName         = $model->$key()->getForeignKeyName();
566
+						$value->$foreignKeyName = $model->id;
567
+						$value->save();
568
+						break;
569
+					case 'BelongsTo':
570
+						/**
571
+						 * Save the model.
572
+						 */
573
+						$value->save();
574
+						$model->$key()->associate($value);
575
+						break;
576
+				}
577
+			}
578
+		}
579
+
580
+		/**
581
+		 * Save the model.
582
+		 */
583
+		$model->save();
584
+
585
+		return $model;
586
+	}
587
+
588
+	/**
589
+	 * Build the conditions recursively for the retrieving methods.
590
+	 * @param  array $conditions
591
+	 * @return array
592
+	 */
593
+	protected function constructConditions($conditions, $model)
594
+	{
595
+		$conditionString = '';
596
+		$conditionValues = [];
597
+		foreach ($conditions as $key => $value) {
598
+			if (Str::contains($key, '->')) {
599
+				$key = $this->wrapJsonSelector($key);
600
+			}
601
+
602
+			if ($key == 'and') {
603
+				$conditions       = $this->constructConditions($value, $model);
604
+				$conditionString .= str_replace('{op}', 'and', $conditions['conditionString']).' {op} ';
605
+				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
606
+			} elseif ($key == 'or') {
607
+				$conditions       = $this->constructConditions($value, $model);
608
+				$conditionString .= str_replace('{op}', 'or', $conditions['conditionString']).' {op} ';
609
+				$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
610
+			} else {
611
+				if (is_array($value)) {
612
+					$operator = $value['op'];
613
+					if (strtolower($operator) == 'between') {
614
+						$value1 = $value['val1'];
615
+						$value2 = $value['val2'];
616
+					} else {
617
+						$value = Arr::get($value, 'val', '');
618
+					}
619
+				} else {
620
+					$operator = '=';
621
+				}
622 622
                 
623
-                if (strtolower($operator) == 'between') {
624
-                    $conditionString  .= $key.' >= ? and ';
625
-                    $conditionValues[] = $value1;
626
-
627
-                    $conditionString  .= $key.' <= ? {op} ';
628
-                    $conditionValues[] = $value2;
629
-                } elseif (strtolower($operator) == 'in') {
630
-                    $conditionValues  = array_merge($conditionValues, $value);
631
-                    $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
632
-                    $conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
633
-                } elseif (strtolower($operator) == 'not in') {
634
-                    $conditionValues  = array_merge($conditionValues, $value);
635
-                    $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
636
-                    $conditionString .= $key.' not in ('.rtrim($inBindingsString, ',').') {op} ';
637
-                } elseif (strtolower($operator) == 'null') {
638
-                    $conditionString .= $key.' is null {op} ';
639
-                } elseif (strtolower($operator) == 'not null') {
640
-                    $conditionString .= $key.' is not null {op} ';
641
-                } elseif (strtolower($operator) == 'has') {
642
-                    $sql              = $model->withTrashed()->withoutGlobalScopes()->has($key)->toSql();
643
-                    $bindings         = $model->withTrashed()->withoutGlobalScopes()->has($key)->getBindings();
644
-                    if($value) {
645
-                        $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
646
-                        $conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
647
-                        $conditionValues  = array_merge($conditionValues, $bindings);
648
-                        $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
649
-                    } else {
650
-                        $conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).') {op} ';
651
-                        $conditionValues  = array_merge($conditionValues, $bindings);
652
-                    }
653
-                } elseif ($operator == 'doesntHave') {
654
-                    $sql              = $model->withTrashed()->withoutGlobalScopes()->whereDoesntHave($key)->toSql();
655
-                    $bindings         = $model->withTrashed()->withoutGlobalScopes()->whereDoesntHave($key)->getBindings();
656
-                    $conditions       = $this->constructConditions($value, $model->$key()->getRelated());
657
-                    $conditionString .= substr(substr($sql, strpos($sql, 'not exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
658
-                    $conditionValues  = array_merge($conditionValues, $bindings);
659
-                    $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
660
-                } else {
661
-                    $conditionString  .= $key.' '.$operator.' ? {op} ';
662
-                    $conditionValues[] = $value;
663
-                }
664
-            }
665
-        }
666
-        $conditionString = '('.rtrim($conditionString, '{op} ').')';
667
-        return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
668
-    }
669
-
670
-    /**
671
-     * Wrap the given JSON selector.
672
-     *
673
-     * @param  string  $value
674
-     * @return string
675
-     */
676
-    protected function wrapJsonSelector($value)
677
-    {
678
-        $removeLast = strpos($value, ')');
679
-        $value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
680
-        $path       = explode('->', $value);
681
-        $field      = array_shift($path);
682
-        $result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
683
-            return '"'.$part.'"';
684
-        })->implode('.'));
623
+				if (strtolower($operator) == 'between') {
624
+					$conditionString  .= $key.' >= ? and ';
625
+					$conditionValues[] = $value1;
626
+
627
+					$conditionString  .= $key.' <= ? {op} ';
628
+					$conditionValues[] = $value2;
629
+				} elseif (strtolower($operator) == 'in') {
630
+					$conditionValues  = array_merge($conditionValues, $value);
631
+					$inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
632
+					$conditionString .= $key.' in ('.rtrim($inBindingsString, ',').') {op} ';
633
+				} elseif (strtolower($operator) == 'not in') {
634
+					$conditionValues  = array_merge($conditionValues, $value);
635
+					$inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
636
+					$conditionString .= $key.' not in ('.rtrim($inBindingsString, ',').') {op} ';
637
+				} elseif (strtolower($operator) == 'null') {
638
+					$conditionString .= $key.' is null {op} ';
639
+				} elseif (strtolower($operator) == 'not null') {
640
+					$conditionString .= $key.' is not null {op} ';
641
+				} elseif (strtolower($operator) == 'has') {
642
+					$sql              = $model->withTrashed()->withoutGlobalScopes()->has($key)->toSql();
643
+					$bindings         = $model->withTrashed()->withoutGlobalScopes()->has($key)->getBindings();
644
+					if($value) {
645
+						$conditions       = $this->constructConditions($value, $model->$key()->getRelated());
646
+						$conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
647
+						$conditionValues  = array_merge($conditionValues, $bindings);
648
+						$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
649
+					} else {
650
+						$conditionString .= substr(substr($sql, strpos($sql, 'exists')), 0, -1).') {op} ';
651
+						$conditionValues  = array_merge($conditionValues, $bindings);
652
+					}
653
+				} elseif ($operator == 'doesntHave') {
654
+					$sql              = $model->withTrashed()->withoutGlobalScopes()->whereDoesntHave($key)->toSql();
655
+					$bindings         = $model->withTrashed()->withoutGlobalScopes()->whereDoesntHave($key)->getBindings();
656
+					$conditions       = $this->constructConditions($value, $model->$key()->getRelated());
657
+					$conditionString .= substr(substr($sql, strpos($sql, 'not exists')), 0, -1).' and '.$conditions['conditionString'].') {op} ';
658
+					$conditionValues  = array_merge($conditionValues, $bindings);
659
+					$conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
660
+				} else {
661
+					$conditionString  .= $key.' '.$operator.' ? {op} ';
662
+					$conditionValues[] = $value;
663
+				}
664
+			}
665
+		}
666
+		$conditionString = '('.rtrim($conditionString, '{op} ').')';
667
+		return ['conditionString' => $conditionString, 'conditionValues' => $conditionValues];
668
+	}
669
+
670
+	/**
671
+	 * Wrap the given JSON selector.
672
+	 *
673
+	 * @param  string  $value
674
+	 * @return string
675
+	 */
676
+	protected function wrapJsonSelector($value)
677
+	{
678
+		$removeLast = strpos($value, ')');
679
+		$value      = $removeLast === false ? $value : substr($value, 0, $removeLast);
680
+		$path       = explode('->', $value);
681
+		$field      = array_shift($path);
682
+		$result     = sprintf('%s->\'$.%s\'', $field, collect($path)->map(function ($part) {
683
+			return '"'.$part.'"';
684
+		})->implode('.'));
685 685
         
686
-        return $removeLast === false ? $result : $result.')';
687
-    }
686
+		return $removeLast === false ? $result : $result.')';
687
+	}
688 688
 }
Please login to merge, or discard this patch.
src/Modules/Core/Setting.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -9,23 +9,23 @@
 block discarded – undo
9 9
 class Setting extends Model
10 10
 {
11 11
 
12
-    use SoftDeletes, Translatable;
13
-    protected $table = 'settings';
14
-    protected $dates = ['created_at', 'updated_at', 'deleted_at'];
15
-    protected $hidden = ['deleted_at'];
16
-    protected $guarded = ['id', 'key'];
17
-    public $fillable = ['name', 'value'];
18
-    public $translatable = ['value'];
19
-    public $casts = ['value' => 'json'];
12
+	use SoftDeletes, Translatable;
13
+	protected $table = 'settings';
14
+	protected $dates = ['created_at', 'updated_at', 'deleted_at'];
15
+	protected $hidden = ['deleted_at'];
16
+	protected $guarded = ['id', 'key'];
17
+	public $fillable = ['name', 'value'];
18
+	public $translatable = ['value'];
19
+	public $casts = ['value' => 'json'];
20 20
     
21
-    public function newCollection(array $models = [])
22
-    {
23
-        return parent::newCollection($models)->keyBy('key');
24
-    }
21
+	public function newCollection(array $models = [])
22
+	{
23
+		return parent::newCollection($models)->keyBy('key');
24
+	}
25 25
 
26
-    public static function boot()
27
-    {
28
-        parent::boot();
29
-        Setting::observe(SettingsObserver::class);
30
-    }
26
+	public static function boot()
27
+	{
28
+		parent::boot();
29
+		Setting::observe(SettingsObserver::class);
30
+	}
31 31
 }
Please login to merge, or discard this patch.
files/Handler.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -9,88 +9,88 @@
 block discarded – undo
9 9
 
10 10
 class Handler extends ExceptionHandler
11 11
 {
12
-    /**
13
-     * A list of the exception types that are not reported.
14
-     *
15
-     * @var array
16
-     */
17
-    protected $dontReport = [
18
-        \League\OAuth2\Server\Exception\OAuthServerException::class,
19
-    ];
12
+	/**
13
+	 * A list of the exception types that are not reported.
14
+	 *
15
+	 * @var array
16
+	 */
17
+	protected $dontReport = [
18
+		\League\OAuth2\Server\Exception\OAuthServerException::class,
19
+	];
20 20
 
21
-    /**
22
-     * A list of the inputs that are never flashed for validation exceptions.
23
-     *
24
-     * @var array
25
-     */
26
-    protected $dontFlash = [
27
-        'password',
28
-        'password_confirmation',
29
-    ];
21
+	/**
22
+	 * A list of the inputs that are never flashed for validation exceptions.
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected $dontFlash = [
27
+		'password',
28
+		'password_confirmation',
29
+	];
30 30
 
31
-    /**
32
-     * Report or log an exception.
33
-     *
34
-     * @param  \Throwable  $exception
35
-     * @return void
36
-     *
37
-     * @throws \Exception
38
-     */
39
-    public function report(Throwable $exception)
40
-    {
41
-        parent::report($exception);
42
-    }
31
+	/**
32
+	 * Report or log an exception.
33
+	 *
34
+	 * @param  \Throwable  $exception
35
+	 * @return void
36
+	 *
37
+	 * @throws \Exception
38
+	 */
39
+	public function report(Throwable $exception)
40
+	{
41
+		parent::report($exception);
42
+	}
43 43
 
44
-    /**
45
-     * Render an exception into an HTTP response.
46
-     *
47
-     * @param  \Illuminate\Http\Request  $request
48
-     * @param  \Throwable  $exception
49
-     * @return \Symfony\Component\HttpFoundation\Response
50
-     *
51
-     * @throws \Throwable
52
-     */
53
-    public function render($request, Throwable $exception)
54
-    {
55
-        $errors = $this->getErrorHandlers();
44
+	/**
45
+	 * Render an exception into an HTTP response.
46
+	 *
47
+	 * @param  \Illuminate\Http\Request  $request
48
+	 * @param  \Throwable  $exception
49
+	 * @return \Symfony\Component\HttpFoundation\Response
50
+	 *
51
+	 * @throws \Throwable
52
+	 */
53
+	public function render($request, Throwable $exception)
54
+	{
55
+		$errors = $this->getErrorHandlers();
56 56
 
57
-        if ($request->wantsJson()) {
58
-            $exceptionClass = get_class($exception);
59
-            return Arr::has($errors, $exceptionClass) ? $errors[$exceptionClass]($request, $exception) : parent::render($request, $exception);
60
-        }
57
+		if ($request->wantsJson()) {
58
+			$exceptionClass = get_class($exception);
59
+			return Arr::has($errors, $exceptionClass) ? $errors[$exceptionClass]($request, $exception) : parent::render($request, $exception);
60
+		}
61 61
 
62
-        return parent::render($request, $exception);
63
-    }
62
+		return parent::render($request, $exception);
63
+	}
64 64
 
65
-    /**
66
-     * Return handler for defined error types
67
-     *
68
-     * @return  array
69
-     */
70
-    protected function getErrorHandlers()
71
-    {
72
-        return [
73
-            \Illuminate\Auth\AuthenticationException::class => function ($request, $exception) {
74
-                Errors::unAuthorized();
75
-            },
76
-            \Illuminate\Database\QueryException::class => function ($request, $exception) {
77
-                Errors::dbQueryError();
78
-            },
79
-            \predis\connection\connectionexception::class => function ($request, $exception) {
80
-                Errors::redisNotRunning();
81
-            },
82
-            \RedisException::class => function ($request, $exception) {
83
-                Errors::redisNotRunning();
84
-            },
85
-            \GuzzleHttp\Exception\ClientException::class => function ($request, $exception) {
86
-                Errors::connectionError();
87
-            },
88
-            \Symfony\Component\HttpKernel\Exception\HttpException::class => function ($request, $exception) {
89
-                return response()->json(['errors' => [$exception->getStatusCode() === 404 ? ($exception->getMessage() ?: 'not found') : $exception->getMessage()]], $exception->getStatusCode());
90
-            },
91
-            \Illuminate\Validation\ValidationException::class => function ($request, $exception) {
92
-                return response()->json(['errors' => $exception->errors()], 422);
93
-            }
94
-        ];
95
-    }
65
+	/**
66
+	 * Return handler for defined error types
67
+	 *
68
+	 * @return  array
69
+	 */
70
+	protected function getErrorHandlers()
71
+	{
72
+		return [
73
+			\Illuminate\Auth\AuthenticationException::class => function ($request, $exception) {
74
+				Errors::unAuthorized();
75
+			},
76
+			\Illuminate\Database\QueryException::class => function ($request, $exception) {
77
+				Errors::dbQueryError();
78
+			},
79
+			\predis\connection\connectionexception::class => function ($request, $exception) {
80
+				Errors::redisNotRunning();
81
+			},
82
+			\RedisException::class => function ($request, $exception) {
83
+				Errors::redisNotRunning();
84
+			},
85
+			\GuzzleHttp\Exception\ClientException::class => function ($request, $exception) {
86
+				Errors::connectionError();
87
+			},
88
+			\Symfony\Component\HttpKernel\Exception\HttpException::class => function ($request, $exception) {
89
+				return response()->json(['errors' => [$exception->getStatusCode() === 404 ? ($exception->getMessage() ?: 'not found') : $exception->getMessage()]], $exception->getStatusCode());
90
+			},
91
+			\Illuminate\Validation\ValidationException::class => function ($request, $exception) {
92
+				return response()->json(['errors' => $exception->errors()], 422);
93
+			}
94
+		];
95
+	}
96 96
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -70,25 +70,25 @@
 block discarded – undo
70 70
     protected function getErrorHandlers()
71 71
     {
72 72
         return [
73
-            \Illuminate\Auth\AuthenticationException::class => function ($request, $exception) {
73
+            \Illuminate\Auth\AuthenticationException::class => function($request, $exception) {
74 74
                 Errors::unAuthorized();
75 75
             },
76
-            \Illuminate\Database\QueryException::class => function ($request, $exception) {
76
+            \Illuminate\Database\QueryException::class => function($request, $exception) {
77 77
                 Errors::dbQueryError();
78 78
             },
79
-            \predis\connection\connectionexception::class => function ($request, $exception) {
79
+            \predis\connection\connectionexception::class => function($request, $exception) {
80 80
                 Errors::redisNotRunning();
81 81
             },
82
-            \RedisException::class => function ($request, $exception) {
82
+            \RedisException::class => function($request, $exception) {
83 83
                 Errors::redisNotRunning();
84 84
             },
85
-            \GuzzleHttp\Exception\ClientException::class => function ($request, $exception) {
85
+            \GuzzleHttp\Exception\ClientException::class => function($request, $exception) {
86 86
                 Errors::connectionError();
87 87
             },
88
-            \Symfony\Component\HttpKernel\Exception\HttpException::class => function ($request, $exception) {
88
+            \Symfony\Component\HttpKernel\Exception\HttpException::class => function($request, $exception) {
89 89
                 return response()->json(['errors' => [$exception->getStatusCode() === 404 ? ($exception->getMessage() ?: 'not found') : $exception->getMessage()]], $exception->getStatusCode());
90 90
             },
91
-            \Illuminate\Validation\ValidationException::class => function ($request, $exception) {
91
+            \Illuminate\Validation\ValidationException::class => function($request, $exception) {
92 92
                 return response()->json(['errors' => $exception->errors()], 422);
93 93
             }
94 94
         ];
Please login to merge, or discard this patch.
files/EventServiceProvider.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,29 +8,29 @@
 block discarded – undo
8 8
 
9 9
 class EventServiceProvider extends ServiceProvider
10 10
 {
11
-    /**
12
-     * The event listener mappings for the application.
13
-     *
14
-     * @var array
15
-     */
16
-    protected $listen = [
17
-        Registered::class => [
18
-            SendEmailVerificationNotification::class,
19
-        ],
20
-        \SocialiteProviders\Manager\SocialiteWasCalled::class => [
21
-            'SocialiteProviders\\Apple\\AppleExtendSocialite@handle',
22
-        ],
23
-    ];
11
+	/**
12
+	 * The event listener mappings for the application.
13
+	 *
14
+	 * @var array
15
+	 */
16
+	protected $listen = [
17
+		Registered::class => [
18
+			SendEmailVerificationNotification::class,
19
+		],
20
+		\SocialiteProviders\Manager\SocialiteWasCalled::class => [
21
+			'SocialiteProviders\\Apple\\AppleExtendSocialite@handle',
22
+		],
23
+	];
24 24
 
25
-    /**
26
-     * Register any events for your application.
27
-     *
28
-     * @return void
29
-     */
30
-    public function boot()
31
-    {
32
-        parent::boot();
25
+	/**
26
+	 * Register any events for your application.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function boot()
31
+	{
32
+		parent::boot();
33 33
 
34
-        //
35
-    }
34
+		//
35
+	}
36 36
 }
Please login to merge, or discard this patch.
files/HttpKernel.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -6,83 +6,83 @@
 block discarded – undo
6 6
 
7 7
 class Kernel extends HttpKernel
8 8
 {
9
-    /**
10
-     * The application's global HTTP middleware stack.
11
-     *
12
-     * These middleware are run during every request to your application.
13
-     *
14
-     * @var array
15
-     */
16
-    protected $middleware = [
17
-        \Fruitcake\Cors\HandleCors::class,
18
-        \App\Http\Middleware\TrustProxies::class,
19
-        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
20
-        \App\Http\Middleware\TrimStrings::class,
21
-        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
22
-    ];
9
+	/**
10
+	 * The application's global HTTP middleware stack.
11
+	 *
12
+	 * These middleware are run during every request to your application.
13
+	 *
14
+	 * @var array
15
+	 */
16
+	protected $middleware = [
17
+		\Fruitcake\Cors\HandleCors::class,
18
+		\App\Http\Middleware\TrustProxies::class,
19
+		\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
20
+		\App\Http\Middleware\TrimStrings::class,
21
+		\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
22
+	];
23 23
 
24
-    /**
25
-     * The application's route middleware groups.
26
-     *
27
-     * @var array
28
-     */
29
-    protected $middlewareGroups = [
30
-        'web' => [
31
-            \App\Http\Middleware\EncryptCookies::class,
32
-            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33
-            \Illuminate\Session\Middleware\StartSession::class,
34
-            // \Illuminate\Session\Middleware\AuthenticateSession::class,
35
-            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
36
-            \App\Http\Middleware\VerifyCsrfToken::class,
37
-            \Illuminate\Routing\Middleware\SubstituteBindings::class,
38
-            'etag'
39
-        ],
24
+	/**
25
+	 * The application's route middleware groups.
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected $middlewareGroups = [
30
+		'web' => [
31
+			\App\Http\Middleware\EncryptCookies::class,
32
+			\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
33
+			\Illuminate\Session\Middleware\StartSession::class,
34
+			// \Illuminate\Session\Middleware\AuthenticateSession::class,
35
+			\Illuminate\View\Middleware\ShareErrorsFromSession::class,
36
+			\App\Http\Middleware\VerifyCsrfToken::class,
37
+			\Illuminate\Routing\Middleware\SubstituteBindings::class,
38
+			'etag'
39
+		],
40 40
 
41
-        'api' => [
42
-            'throttle:60,1',
43
-            \Illuminate\Routing\Middleware\SubstituteBindings::class,
44
-            \App\Modules\Core\Http\Middleware\SetSessions::class,
45
-            \App\Modules\Core\Http\Middleware\CheckPermissions::class,
46
-            \App\Modules\Core\Http\Middleware\UpdateLocaleAndTimezone::class,
47
-            \App\Modules\Core\Http\Middleware\SetRelations::class,
48
-            'etag'
49
-        ],
50
-    ];
41
+		'api' => [
42
+			'throttle:60,1',
43
+			\Illuminate\Routing\Middleware\SubstituteBindings::class,
44
+			\App\Modules\Core\Http\Middleware\SetSessions::class,
45
+			\App\Modules\Core\Http\Middleware\CheckPermissions::class,
46
+			\App\Modules\Core\Http\Middleware\UpdateLocaleAndTimezone::class,
47
+			\App\Modules\Core\Http\Middleware\SetRelations::class,
48
+			'etag'
49
+		],
50
+	];
51 51
 
52
-    /**
53
-     * The application's route middleware.
54
-     *
55
-     * These middleware may be assigned to groups or used individually.
56
-     *
57
-     * @var array
58
-     */
59
-    protected $routeMiddleware = [
60
-        'auth' => \App\Http\Middleware\Authenticate::class,
61
-        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
62
-        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
63
-        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
64
-        'can' => \Illuminate\Auth\Middleware\Authorize::class,
65
-        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
66
-        'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
67
-        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
68
-        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
69
-        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
70
-    ];
52
+	/**
53
+	 * The application's route middleware.
54
+	 *
55
+	 * These middleware may be assigned to groups or used individually.
56
+	 *
57
+	 * @var array
58
+	 */
59
+	protected $routeMiddleware = [
60
+		'auth' => \App\Http\Middleware\Authenticate::class,
61
+		'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
62
+		'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
63
+		'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
64
+		'can' => \Illuminate\Auth\Middleware\Authorize::class,
65
+		'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
66
+		'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class,
67
+		'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
68
+		'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
69
+		'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
70
+	];
71 71
 
72
-    /**
73
-     * The priority-sorted list of middleware.
74
-     *
75
-     * This forces non-global middleware to always be in the given order.
76
-     *
77
-     * @var array
78
-     */
79
-    protected $middlewarePriority = [
80
-        \Illuminate\Session\Middleware\StartSession::class,
81
-        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
82
-        \App\Http\Middleware\Authenticate::class,
83
-        \Illuminate\Routing\Middleware\ThrottleRequests::class,
84
-        \Illuminate\Session\Middleware\AuthenticateSession::class,
85
-        \Illuminate\Routing\Middleware\SubstituteBindings::class,
86
-        \Illuminate\Auth\Middleware\Authorize::class,
87
-    ];
72
+	/**
73
+	 * The priority-sorted list of middleware.
74
+	 *
75
+	 * This forces non-global middleware to always be in the given order.
76
+	 *
77
+	 * @var array
78
+	 */
79
+	protected $middlewarePriority = [
80
+		\Illuminate\Session\Middleware\StartSession::class,
81
+		\Illuminate\View\Middleware\ShareErrorsFromSession::class,
82
+		\App\Http\Middleware\Authenticate::class,
83
+		\Illuminate\Routing\Middleware\ThrottleRequests::class,
84
+		\Illuminate\Session\Middleware\AuthenticateSession::class,
85
+		\Illuminate\Routing\Middleware\SubstituteBindings::class,
86
+		\Illuminate\Auth\Middleware\Authorize::class,
87
+	];
88 88
 }
Please login to merge, or discard this patch.
src/ApiSkeletonServiceProvider.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -6,42 +6,42 @@
 block discarded – undo
6 6
 
7 7
 class ApiSkeletonServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Perform post-registration booting of services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->publishes([
17
-            __DIR__.'/Modules'                               => app_path('Modules'),
18
-            __DIR__.'/Modules/Core/Resources/Assets'         => base_path('public/doc/assets'),
19
-            __DIR__.'/../lang'                               => base_path('resources/lang'),
20
-            __DIR__.'/../files/Handler.php'                  => app_path('Exceptions/Handler.php'),
21
-            __DIR__.'/../files/AuthServiceProvider.php'      => app_path('Providers/AuthServiceProvider.php'),
22
-            __DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'),
23
-            __DIR__.'/../files/EventServiceProvider.php'     => app_path('Providers/EventServiceProvider.php'),
24
-            __DIR__.'/../files/Kernel.php'                   => app_path('Console/Kernel.php'),
25
-            __DIR__.'/../files/HttpKernel.php'               => app_path('Http/Kernel.php'),
26
-            __DIR__.'/../files/channels.php'                 => base_path('routes/channels.php'),
27
-            __DIR__.'/../files/Jenkinsfile'                  => base_path('/Jenkinsfile'),
28
-            __DIR__.'/../files/phpcs.xml'                    => base_path('/phpcs.xml'),
29
-            __DIR__.'/../files/docker'                       => base_path('/docker'),
30
-            __DIR__.'/../files/.dockerignore'                => base_path('/.dockerignore'),
31
-        ]);
9
+	/**
10
+	 * Perform post-registration booting of services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->publishes([
17
+			__DIR__.'/Modules'                               => app_path('Modules'),
18
+			__DIR__.'/Modules/Core/Resources/Assets'         => base_path('public/doc/assets'),
19
+			__DIR__.'/../lang'                               => base_path('resources/lang'),
20
+			__DIR__.'/../files/Handler.php'                  => app_path('Exceptions/Handler.php'),
21
+			__DIR__.'/../files/AuthServiceProvider.php'      => app_path('Providers/AuthServiceProvider.php'),
22
+			__DIR__.'/../files/BroadcastServiceProvider.php' => app_path('Providers/BroadcastServiceProvider.php'),
23
+			__DIR__.'/../files/EventServiceProvider.php'     => app_path('Providers/EventServiceProvider.php'),
24
+			__DIR__.'/../files/Kernel.php'                   => app_path('Console/Kernel.php'),
25
+			__DIR__.'/../files/HttpKernel.php'               => app_path('Http/Kernel.php'),
26
+			__DIR__.'/../files/channels.php'                 => base_path('routes/channels.php'),
27
+			__DIR__.'/../files/Jenkinsfile'                  => base_path('/Jenkinsfile'),
28
+			__DIR__.'/../files/phpcs.xml'                    => base_path('/phpcs.xml'),
29
+			__DIR__.'/../files/docker'                       => base_path('/docker'),
30
+			__DIR__.'/../files/.dockerignore'                => base_path('/.dockerignore'),
31
+		]);
32 32
 
33
-        $this->publishes([
34
-            __DIR__.'/../files/auth.php' => config_path('auth.php'),
35
-        ], 'config');
36
-    }
33
+		$this->publishes([
34
+			__DIR__.'/../files/auth.php' => config_path('auth.php'),
35
+		], 'config');
36
+	}
37 37
 
38
-    /**
39
-     * Register any package services.
40
-     *
41
-     * @return void
42
-     */
43
-    public function register()
44
-    {
45
-        //
46
-    }
38
+	/**
39
+	 * Register any package services.
40
+	 *
41
+	 * @return void
42
+	 */
43
+	public function register()
44
+	{
45
+		//
46
+	}
47 47
 }
Please login to merge, or discard this patch.
src/Modules/Reporting/Providers/ModuleServiceProvider.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 
7 7
 class ModuleServiceProvider extends ServiceProvider
8 8
 {
9
-    /**
10
-     * Bootstrap the module services.
11
-     *
12
-     * @return void
13
-     */
14
-    public function boot()
15
-    {
16
-        $this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'reporting');
17
-        $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'reporting');
9
+	/**
10
+	 * Bootstrap the module services.
11
+	 *
12
+	 * @return void
13
+	 */
14
+	public function boot()
15
+	{
16
+		$this->loadTranslationsFrom(__DIR__.'/../Resources/Lang', 'reporting');
17
+		$this->loadViewsFrom(__DIR__.'/../Resources/Views', 'reporting');
18 18
 
19
-        $this->loadMigrationsFrom(module_path('reporting', 'Database/Migrations', 'app'));
20
-        if (!$this->app->configurationIsCached()) {
21
-            $this->loadConfigsFrom(module_path('reporting', 'Config', 'app'));
22
-        }
23
-    }
19
+		$this->loadMigrationsFrom(module_path('reporting', 'Database/Migrations', 'app'));
20
+		if (!$this->app->configurationIsCached()) {
21
+			$this->loadConfigsFrom(module_path('reporting', 'Config', 'app'));
22
+		}
23
+	}
24 24
 
25
-    /**
26
-     * Register the module services.
27
-     *
28
-     * @return void
29
-     */
30
-    public function register()
31
-    {
32
-        $this->app->register(RouteServiceProvider::class);
33
-    }
25
+	/**
26
+	 * Register the module services.
27
+	 *
28
+	 * @return void
29
+	 */
30
+	public function register()
31
+	{
32
+		$this->app->register(RouteServiceProvider::class);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
         $this->loadViewsFrom(__DIR__.'/../Resources/Views', 'reporting');
18 18
 
19 19
         $this->loadMigrationsFrom(module_path('reporting', 'Database/Migrations', 'app'));
20
-        if (!$this->app->configurationIsCached()) {
20
+        if ( ! $this->app->configurationIsCached()) {
21 21
             $this->loadConfigsFrom(module_path('reporting', 'Config', 'app'));
22 22
         }
23 23
     }
Please login to merge, or discard this patch.