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