<?php
namespace App\Http\Requests\Admin\Category;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
class CategoryPostRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(Request $request)
{
return [
'name' => $request->category_id ? 'required|max:191|unique:categories,name,'.$request->category_id.',id' : 'required|max:191|unique:categories,name',
'description' => ['required'],
'picture' => ['mimes:jpg,png,jpeg']
];
}
/**
* Custom Validation Errors.
*
* @return array
*/
public function messages()
{
return ['exists' => tr('category_not_found') ];
}
}