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

28 lines
565 B
PHP
Raw 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 CategoryRequest extends FormRequest
{
public function authorize()
{
return true;
}
public function rules(Request $request)
{
$unique = !empty($request['item_id']) ? ',' . $request['item_id'] :'';
return [
'title' => 'required',
'url' => 'required|regex:/^[a-z\d-]+$/|unique:categories,url'.$unique,
'article' => 'required',
'image' => 'image',
];
}
}