PATH:
home
/
rwabteecom
/
project_11
/
app
/
Http
/
Controllers
/
Admin
/
Theme
/
Editing: ThemeController.php
<?php namespace App\Http\Controllers\Admin\Theme; use App\Datatables\ThemeDatatables; use App\Http\Controllers\Controller; use App\Http\Requests\Admin\Theme\ThemeRequest; use App\Services\Feature\FeatureServices; use App\Services\Theme\ThemeServices; use Exception; use Illuminate\Http\Request; use Log; class ThemeController extends Controller { public function __construct(private readonly ThemeDatatables $themeDatatables, private readonly ThemeServices $themeServices, private readonly FeatureServices $featureServices) { } public function index(Request $request) { if (request()->expectsJson()) { return $this->themeDatatables->datatables($request); } return view("admin.pages.themes.index")->with([ "columns" => $this->themeDatatables::columns(), ]); } public function create() { return view("admin.pages.themes.create")->with([ 'features' => $this->featureServices->index(true), ]); } public function store(ThemeRequest $request) { try { $this->themeServices->store($request); } catch (Exception $exception) { Log::error($exception->getMessage()); return back()->withInput()->with('error', $exception->getMessage()); } return back()->with("success", __("Theme added Successfully")); } public function edit($id) { return view("admin.pages.themes.edit")->with([ "theme" => $this->themeServices->findOrFail($id), 'features' => $this->featureServices->index(), ]); } public function update(ThemeRequest $request, $id) { try { $this->themeServices->update($id, $request); } catch (Exception $exception) { Log::error($exception->getMessage()); return back()->withInput()->with('error', $exception->getMessage()); } return back()->with("success", __("Theme updated Successfully")); } public function destroy($id) { try { $this->themeServices->destroy($id); } catch (Exception $exception) { Log::error($exception->getMessage()); return $this->sendFailedResponse($exception->getMessage()); } return $this->sendSuccessResponse(message: __("Theme deleted Successfully")); } }
SAVE
CANCEL