@@ -121,29 +121,19 @@ public function getApiCollectionWithModel($model)
121121
122122 public function getRepositoryFunctions ($ model , $ function_name , array $ params = [])
123123 {
124+ $ collection_class = $ this ->getApiCollectionWithModel ($ this ->model );
124125
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 ));
137128
129+ if (class_exists ($ collection_class )) {
138130
139- return call_user_func ([$ class , camel_case ($ function_name )], $ params );
131+ // Set ApiCollection
132+ $ class = app ($ collection_class );
133+ }
140134
141135
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 );
147137 }
148138
149139 public function returnRaw ($ raw , $ builder )
@@ -171,7 +161,7 @@ public function returnRaw($raw, $builder)
171161 */
172162 $ offset = $ limit * (app ('request ' )->get ('page ' , 1 ) - 1 );
173163
174- if ($ builder ->getOption ('paginate ' ,true )) {
164+ if ($ builder ->getOption ('paginate ' , true )) {
175165 $ query .= " LIMIT " . $ limit . " OFFSET " . $ offset ;
176166 }
177167
@@ -253,7 +243,7 @@ public function returnQuerying($query, $builder)
253243 */
254244 $ offset = $ limit * (app ('request ' )->get ('page ' , 1 ) - 1 );
255245
256- if ($ builder ->getOption ('paginate ' ,true )) {
246+ if ($ builder ->getOption ('paginate ' , true )) {
257247 $ query ->take ($ limit )->offset ($ offset );
258248 }
259249
0 commit comments