form = AssetTypeForm::grouped(false) ->setAttributes() ->toArray(); $this->modules = $this->modules(config('assetise.asset_type.modules'), 'asset_type', guard_url('asset_type')); } /** * Display a list of asset_type. * * @return Response */ public function index(AssetTypeRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $page = AssetType::pushScope(new RequestScope()) ->pushScope(new AssetTypeResourceScope()) ->simplePaginate($pageLimit); $data = new AssetTypesCollection($page); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('asset_type::asset_type.names')) ->view('asset_type::asset_type.index') ->data(compact('data', 'modules', 'form')) ->output(); } /** * Display asset_type. * * @param Request $request * @param Model $asset_type * * @return Response */ public function show(AssetTypeRequest $request, AssetType $model) { $form = $this->form; $modules = $this->modules; $data = new AssetTypeResource($model); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('asset_type::asset_type.name')) ->data(compact('data', 'form', 'modules')) ->view('asset_type::asset_type.show') ->output(); } /** * Show the form for creating a new asset_type. * * @param Request $request * * @return Response */ public function create(AssetTypeRequest $request, AssetType $model) { $form = $this->form; $modules = $this->modules; $data = new AssetTypeResource($model); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('asset_type::asset_type.name')) ->view('asset_type::asset_type.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new asset_type. * * @param Request $request * * @return Response */ public function store(AssetTypeRequest $request, AssetType $model) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $model = $model->create($attributes); $data = new AssetTypeResource($model); return $this->response->message(trans('messages.success.created', ['Module' => trans('asset_type::asset_type.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('asset_type/asset_type/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/asset_type/asset_type')) ->redirect(); } } /** * Show asset_type for editing. * * @param Request $request * @param Model $asset_type * * @return Response */ public function edit(AssetTypeRequest $request, AssetType $model) { $form = $this->form; $modules = $this->modules; $data = new AssetTypeResource($model); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('asset_type::asset_type.name')) ->view('asset_type::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(AssetTypeRequest $request, AssetType $model) { try { $attributes = $request->all(); $model = $model->update($attributes); $data = new AssetTypeResource($model); return $this->response->message(trans('messages.success.updated', ['Module' => trans('asset_type::asset_type.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('asset_type/asset_type/' . $model->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('asset_type/asset_type/' . $model->getRouteKey())) ->redirect(); } } /** * Remove the asset_type. * * @param Model $asset_type * * @return Response */ public function destroy(AssetTypeRequest $request, AssetType $model) { try { $model->delete(); $data = new AssetTypeResource($model); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('asset_type::asset_type.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('asset_type/asset_type/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('asset_type/asset_type/' . $model->getRouteKey())) ->redirect(); } } }