Eshop-Laravel/app/Http/Requests/MenuRequest.php
2019-10-18 12:25:37 +03:00

26 lines
523 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
class MenuRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules(Request $request)
{
$unique = !empty($request['item_id']) ? ',' . $request['item_id'] :'';
return [
'link' => 'required',
'title' => 'required',
'url' => 'required|regex:/^[a-z\d-]+$/|unique:menus,url'.$unique,
];
}
}