32 lines
729 B
PHP
32 lines
729 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Requests;
|
||
|
|
||
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
use Illuminate\Http\Request;
|
||
|
|
||
|
class ProductRequest extends FormRequest
|
||
|
{
|
||
|
|
||
|
public function authorize()
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
|
||
|
public function rules(Request $request)
|
||
|
{
|
||
|
$unique = !empty($request['item_id']) ? ',' . $request['item_id'] :'';
|
||
|
return [
|
||
|
'categorie_id' => 'required|numeric',
|
||
|
'title' => 'required',
|
||
|
'url' => 'required|regex:/^[a-z\d-]+$/|unique:products,url'.$unique,
|
||
|
'price' => 'required|numeric',
|
||
|
'stock' => 'required|numeric',
|
||
|
'sale' => 'required|numeric',
|
||
|
'body' => 'required',
|
||
|
'image' => 'image',
|
||
|
];
|
||
|
}
|
||
|
}
|