fix: 🐛 dynamically define the target table when storing a new rating #310
This commit is contained in:
parent
0b927200e9
commit
49310fa195
1 changed files with 3 additions and 1 deletions
|
|
@ -23,9 +23,11 @@ class StoreRatingRequest extends FormRequest
|
|||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$table = $this->rating_type === 'App\Models\Product' ? 'products' : 'recipes';
|
||||
|
||||
return [
|
||||
'rate' => 'required|integer|min:0|max:5',
|
||||
'rating_id' => 'required|integer|exists:products,id',
|
||||
'rating_id' => "required|integer|exists:{$table},id",
|
||||
'rating_type' => 'required|in:App\\Models\\Product,App\\Models\\Recipe',
|
||||
'customer_id' => 'required|integer|exists:customers,id',
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue