forked from aslan/applicant-site
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?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)
|
|
{
|
|
|
|
$validated = $request->validated();
|
|
$feedback = new Feedback();
|
|
|
|
$feedback->contact = $validated['contact'];
|
|
$feedback->text = $validated['text'];
|
|
$feedback->status_id = 1;
|
|
$feedback->save();
|
|
|
|
flash('Ваше сообщение отправлено!')->success();
|
|
|
|
return back();
|
|
}
|
|
|
|
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');
|
|
}
|
|
}
|