Eshop-Laravel/app/Http/Requests/MenuRequest.php

27 lines
523 B
PHP
Raw Permalink Normal View History

2019-10-18 09:25:37 +00:00
<?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,
];
}
}