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