repository = $studious; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Btravel\Studio\Repositories\Criteria\StudiousResourceCriteria::class); } /** * Display a list of studious. * * @return Response */ public function index(StudiousRequest $request) { return $this->repository ->setPresenter(\Btravel\Studio\Repositories\Presenter\StudiousPresenter::class) ->paginate(); } /** * Display studious. * * @param Request $request * @param Model $studious * * @return Response */ public function show(StudiousRequest $request, Studious $studious) { return $studious->setPresenter(\Btravel\Studio\Repositories\Presenter\StudiousListPresenter::class); ; } /** * Create new studious. * * @param Request $request * * @return Response */ public function store(StudiousRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('studio::studious.name')]); $code = 204; $status = 'success'; $url = guard_url('studio/studious/' . $studious->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('studio/studious'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the studious. * * @param Request $request * @param Model $studious * * @return Response */ public function update(StudiousRequest $request, Studious $studious) { try { $data = $request->all(); $studious->update($data); $message = trans('messages.success.updated', ['Module' => trans('studio::studious.name')]); $code = 204; $status = 'success'; $url = guard_url('studio/studious/' . $studious->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('studio/studious/' . $studious->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the studious. * * @param Model $studious * * @return Response */ public function destroy(StudiousRequest $request, Studious $studious) { try { $studious->delete(); $message = trans('messages.success.deleted', ['Module' => trans('studio::studious.name')]); $code = 202; $status = 'success'; $url = guard_url('studio/studious/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('studio/studious/' . $studious->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }