Roman_applicant-site/app/Http/Controllers/admin/FeedbackStatusController.php

56 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers\admin;
use App\Http\Controllers\Controller;
use App\Http\Requests\admin\StoreFeedbackStatusRequest;
use App\Http\Requests\admin\UpdateFeedbackStatusRequest;
use App\Models\FeedbackStatus;
class FeedbackStatusController extends Controller
{
public function index()
{
$feedbackStatuses = FeedbackStatus::all();
return view('admin.feedback_statuses.index', compact('feedbackStatuses'));
}
public function create()
{
return view('admin.feedback_statuses.create');
}
public function store(StoreFeedbackStatusRequest $request)
{
$validated = $request->validated();
$feedbackStatus = new FeedbackStatus();
$feedbackStatus->name = $validated['name'];
$feedbackStatus->save();
return redirect()->route('feedback_statuses.index');
}
public function edit(FeedbackStatus $feedbackStatus)
{
return view('admin.feedback_statuses.edit', compact('feedbackStatus'));
}
public function update(UpdateFeedbackStatusRequest $request, FeedbackStatus $feedbackStatus)
{
$validated = $request->validated();
$feedbackStatus->name = $validated['name'];
$feedbackStatus->save();
return redirect()->route('feedback_statuses.index');
}
public function destroy(FeedbackStatus $feedbackStatus)
{
if ($feedbackStatus->feedbacks()->exists()) {
return back();
}
$feedbackStatus->delete();
return redirect()->route('feedback_statuses.index');
}
}