@@ -121,29 +121,19 @@ public function getApiCollectionWithModel($model)
121
121
122
122
public function getRepositoryFunctions ($ model , $ function_name , array $ params = [])
123
123
{
124
+ $ collection_class = $ this ->getApiCollectionWithModel ($ this ->model );
124
125
125
- try {
126
-
127
- $ collection_class = $ this ->getApiCollectionWithModel ($ this ->model );
128
-
129
- // Default set Repository
130
- $ class = app ($ this ->getRepositoryWithModel ($ model ));
131
-
132
- if (class_exists ($ collection_class )) {
133
-
134
- // Set ApiCollection
135
- $ class = app ($ collection_class );
136
- }
126
+ // Default set Repository
127
+ $ class = app ($ this ->getRepositoryWithModel ($ model ));
137
128
129
+ if (class_exists ($ collection_class )) {
138
130
139
- return call_user_func ([$ class , camel_case ($ function_name )], $ params );
131
+ // Set ApiCollection
132
+ $ class = app ($ collection_class );
133
+ }
140
134
141
135
142
- } catch (\Exception $ exception ) {
143
- header ('Content-Type: application/json ' );
144
- echo json_encode (['status ' => false , 'message ' => $ exception ->getMessage ()]);
145
- die;
146
- }
136
+ return call_user_func ([$ class , camel_case ($ function_name )], $ params );
147
137
}
148
138
149
139
public function returnRaw ($ raw , $ builder )
@@ -171,7 +161,7 @@ public function returnRaw($raw, $builder)
171
161
*/
172
162
$ offset = $ limit * (app ('request ' )->get ('page ' , 1 ) - 1 );
173
163
174
- if ($ builder ->getOption ('paginate ' ,true )) {
164
+ if ($ builder ->getOption ('paginate ' , true )) {
175
165
$ query .= " LIMIT " . $ limit . " OFFSET " . $ offset ;
176
166
}
177
167
@@ -253,7 +243,7 @@ public function returnQuerying($query, $builder)
253
243
*/
254
244
$ offset = $ limit * (app ('request ' )->get ('page ' , 1 ) - 1 );
255
245
256
- if ($ builder ->getOption ('paginate ' ,true )) {
246
+ if ($ builder ->getOption ('paginate ' , true )) {
257
247
$ query ->take ($ limit )->offset ($ offset );
258
248
}
259
249
0 commit comments