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