48 lines
1.3 KiB
PHP
48 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Admin\TestimonialRequest;
|
|
use App\Models\Testimonial;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class TestimonialController extends Controller
|
|
{
|
|
public function index(): Response
|
|
{
|
|
return Inertia::render('admin/testimonials/index', [
|
|
'testimonials' => Testimonial::query()->orderBy('sort_order')->orderBy('id')->get(),
|
|
]);
|
|
}
|
|
|
|
public function store(TestimonialRequest $request): RedirectResponse
|
|
{
|
|
Testimonial::query()->create($request->validated());
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Testimoni ditambahkan.']);
|
|
|
|
return back();
|
|
}
|
|
|
|
public function update(TestimonialRequest $request, Testimonial $testimonial): RedirectResponse
|
|
{
|
|
$testimonial->update($request->validated());
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Testimoni diperbarui.']);
|
|
|
|
return back();
|
|
}
|
|
|
|
public function destroy(Testimonial $testimonial): RedirectResponse
|
|
{
|
|
$testimonial->delete();
|
|
|
|
Inertia::flash('toast', ['type' => 'success', 'message' => 'Testimoni dihapus.']);
|
|
|
|
return back();
|
|
}
|
|
}
|