/** * Handle 'limit', 'skip', 'sort_field', 'sort_dir' get params possibly sent by ajax request * @param $modelClassName : the name of the model to create (Ex: 'Event', 'User', ...) * @param $request : Instance of Illuminate\Http\Request containing get params * @return model : the model to create */ function handleUrlParams($modelClassName, Illuminate\Http\Request $request) { $className = 'App\\' . $modelClassName; if (!class_exists($className)) { abort(400, 'Bad $modelClassName sent to function handleUrlParams(): the class doesn\'t exist'); } $model = new $className(); $model = $model->newQuery(); return applyParams($model, $request); }
protected function getParticipantsOf() { $data = EventUser::where('event_user.event_id', $this->request->event_id)->join('users', 'event_user.user_id', '=', 'users.id'); $data = applyParams($data, $this->request)->get(); return data(compact('data')); }