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