<?php
namespace QxCMS\Modules\Client\Requests\Products;
use Illuminate\Foundation\Http\FormRequest;
class ProductRequest 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()
{
return [
'name' => 'required|min:3|unique:client.products,name,'.($this->getId() ? $this->getId() : NULL).',id',
'brand_id' => 'required',
'category_id' => 'required',
'price' => 'numeric',
'year' => 'numeric',
'details' => 'required',
'image' => 'image',
];
}
public function messages()
{
return [
'name.required' => 'Product name is required.',
'brand_id.required' => 'Product Brand is required.',
'category_id.required' => 'Product Category is required.',
'details.required' => 'Details is required.',
'image.image' => 'This must be an image.',
];
}
public function getId()
{
return decode($this->id);
}
}