repository = $developers; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Bixo\Developer\Repositories\Criteria\DevelopersResourceCriteria::class); } /** * Display a list of developers. * * @return Response */ public function index(DevelopersRequest $request) { return $this->repository ->setPresenter(\Bixo\Developer\Repositories\Presenter\DevelopersPresenter::class) ->paginate(); } /** * Display developers. * * @param Request $request * @param Model $developers * * @return Response */ public function show(DevelopersRequest $request, Developers $developers) { return $developers->setPresenter(\Bixo\Developer\Repositories\Presenter\DevelopersListPresenter::class); ; } /** * Create new developers. * * @param Request $request * * @return Response */ public function store(DevelopersRequest $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('developer::developers.name')]); $code = 204; $status = 'success'; $url = guard_url('developer/developers/' . $developers->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('developer/developers'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the developers. * * @param Request $request * @param Model $developers * * @return Response */ public function update(DevelopersRequest $request, Developers $developers) { try { $data = $request->all(); $developers->update($data); $message = trans('messages.success.updated', ['Module' => trans('developer::developers.name')]); $code = 204; $status = 'success'; $url = guard_url('developer/developers/' . $developers->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('developer/developers/' . $developers->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the developers. * * @param Model $developers * * @return Response */ public function destroy(DevelopersRequest $request, Developers $developers) { try { $developers->delete(); $message = trans('messages.success.deleted', ['Module' => trans('developer::developers.name')]); $code = 202; $status = 'success'; $url = guard_url('developer/developers/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('developer/developers/' . $developers->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); } }