authorizeResource(Explorerpage::class); } /** * Display a listing of the resource. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Contracts\View\View */ public function index(Request $request): \Illuminate\Contracts\View\View { /** @var \Illuminate\Database\Eloquent\Builder $explorerpageModels */ $explorerpageModels = Explorerpage::query(); /** @var string $search Search field */ $search = $request->search; if ($search) { $this->searchQuery( $explorerpageModels, $search, null, 'picture_1_title', 'picture_2_title', 'picture_3_title' ); } $searchFields = \implode(', ', [ Str::ucfirst(trans('validation.attributes.title')) ]); /** Sort columns with a query */ $this->sortQuery($explorerpageModels); /** Custom pagination */ $explorerpageModels = $this->paginate($explorerpageModels); return view('bo.pages.explorerpages.index', compact('explorerpageModels', 'search', 'searchFields')); } /** * Show the form for editing the specified resource. * * @param App\Models\Explorerpage $explorerpage * @return \Illuminate\Contracts\View\View */ public function edit(Explorerpage $explorerpage): \Illuminate\Contracts\View\View { $commitmentModels = Commitment::all(); return view('bo.pages.explorerpages.edit', [ 'explorerpageModel' => $explorerpage, 'commitmentModels' => $commitmentModels, ]); } /** * Update the specified resource in storage. * * @param \App\Http\Requests\Bo\Explorerpages\UpdateExplorerpageRequest $request * @param \App\Models\Explorerpage $explorerpage * @return \Illuminate\Http\RedirectResponse */ public function update( UpdateExplorerpageRequest $request, Explorerpage $explorerpage ): \Illuminate\Http\RedirectResponse { return DB::transaction(function () use ($request, $explorerpage) { $explorerpage->fill($request->safe()->except('commitments')); $explorerpage->commitments()->sync(\collect($request->validated('commitments'))->pluck('id')); if ($explorerpage->saveOrFail()) { return redirect()->route('bo.explorerpages.edit', $explorerpage) ->with('success', __('crud.messages.has_been_updated', [ 'model' => Str::ucfirst(__('models.classes.explorerpage')) ])); } return redirect()->route('bo.explorerpages.edit', $explorerpage) ->with('error', __('crud.messages.cannot_be_updated', [ 'model' => Str::ucfirst(__('models.classes.explorerpage')) ])); }); } }