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