2024-04-23 14:23:21 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\admin;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Http\Requests\admin\StoreFeedbackRequest;
|
|
|
|
use App\Http\Requests\admin\UpdateFeedbackRequest;
|
|
|
|
use App\Models\Feedback;
|
|
|
|
use App\Models\FeedbackStatus;
|
|
|
|
|
|
|
|
class FeedbackController extends Controller
|
|
|
|
{
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$feedbacks = Feedback::all();
|
|
|
|
return view('admin.feedback.index', compact('feedbacks'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function store(StoreFeedbackRequest $request)
|
|
|
|
{
|
2024-04-24 15:27:07 +03:00
|
|
|
|
2024-04-23 14:23:21 +03:00
|
|
|
$validated = $request->validated();
|
|
|
|
$feedback = new Feedback();
|
|
|
|
|
|
|
|
$feedback->contact = $validated['contact'];
|
|
|
|
$feedback->text = $validated['text'];
|
2024-04-24 15:27:07 +03:00
|
|
|
$feedback->status_id = 1;
|
2024-04-23 14:23:21 +03:00
|
|
|
$feedback->save();
|
|
|
|
|
2024-04-24 15:27:07 +03:00
|
|
|
flash('Ваше сообщение отправлено!')->success();
|
|
|
|
|
|
|
|
return back();
|
2024-04-23 14:23:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function edit(Feedback $feedback)
|
|
|
|
{
|
|
|
|
$feedbackStatuses = FeedbackStatus::pluck('name', 'id');
|
|
|
|
return view('admin.feedback.edit', compact('feedback', 'feedbackStatuses'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function update(UpdateFeedbackRequest $request, Feedback $feedback)
|
|
|
|
{
|
|
|
|
$validated = $request->validated();
|
|
|
|
|
|
|
|
$feedback->contact = $validated['contact'];
|
|
|
|
$feedback->text = $validated['text'];
|
|
|
|
$feedback->status_id = $validated['status_id'];
|
|
|
|
$feedback->save();
|
|
|
|
|
|
|
|
return redirect()->route('feedback.index');
|
|
|
|
}
|
|
|
|
}
|