19 lines
675 B
PHP
19 lines
675 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Booking;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ReviewController extends Controller
|
|
{
|
|
public function store(Request $r, Booking $booking)
|
|
{
|
|
abort_unless($booking->client_id === $r->user()->id && $booking->status === 'completed', 403);
|
|
$d = $r->validate(['rating' => 'required|integer|min:1|max:5', 'title' => 'nullable|string|max:100', 'body' => 'required|string|max:3000']);
|
|
$booking->djProfile?->reviews()->create($d + ['booking_id' => $booking->id, 'user_id' => $r->user()->id, 'status' => 'pending']);
|
|
|
|
return back()->with('success', 'Review submitted for moderation.');
|
|
}
|
|
}
|