form = AssetLocationForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('assetise.asset.modules'), 'asset', guard_url('asset')); } /** * Display a list of asset_location. * * @return Response */ public function index(AssetLocationResourceRequest $request) { $request = $request->all(); $page = AssetLocationActions::run('paginate', $request); $data = new AssetLocationsCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('asset::asset_location.names')) ->view('asset::asset_location.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display asset_location. * * @param Request $request * @param Model $asset_location * * @return Response */ public function show(AssetLocationResourceRequest $request, AssetLocation $model) { $form = $this->form; $modules = $this->modules; $data = new AssetLocationResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('asset::asset_location.name')) ->data(compact('data', 'form', 'modules')) ->view('asset::asset_location.show') ->output(); } /** * Show the form for creating a new asset_location. * * @param Request $request * * @return Response */ public function create(AssetLocationResourceRequest $request, AssetLocation $model) { $form = $this->form; $modules = $this->modules; $data = new AssetLocationResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('asset::asset_location.name')) ->view('asset::asset_location.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new asset_location. * * @param Request $request * * @return Response */ public function store(AssetLocationResourceRequest $request, AssetLocation $model) { try { $request = $request->all(); $model = AssetLocationAction::run('store', $model, $request); $data = new AssetLocationResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('asset::asset_location.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('asset/asset_location/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/asset/asset_location')) ->redirect(); } } /** * Show asset_location for editing. * * @param Request $request * @param Model $asset_location * * @return Response */ public function edit(AssetLocationResourceRequest $request, AssetLocation $model) { $form = $this->form; $modules = $this->modules; $data = new AssetLocationResource($model); // return view('asset::asset_location.edit', compact('data', 'form', 'modules')); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('asset::asset_location.name')) ->view('asset::asset_location.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the asset_location. * * @param Request $request * @param Model $asset_location * * @return Response */ public function update(AssetLocationResourceRequest $request, AssetLocation $model) { try { $request = $request->all(); $model = AssetLocationAction::run('update', $model, $request); $data = new AssetLocationResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('asset::asset_location.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('asset/asset_location/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('asset/asset_location/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the asset_location. * * @param Model $asset_location * * @return Response */ public function destroy(AssetLocationResourceRequest $request, AssetLocation $model) { try { $request = $request->all(); $model = AssetLocationAction::run('destroy', $model, $request); $data = new AssetLocationResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('asset::asset_location.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('asset/asset_location/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('asset/asset_location/' . $model->getRouteKey())) ->redirect(); } } }