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