ldc-legaulois/app/Http/Requests/StoreLabel.php
2021-11-29 09:31:29 +01:00

37 lines
819 B
PHP

<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Str;
class StoreLabel extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (!$this->status) {
$this->request->add(['status' => false]);
}
$this->request->add(['slug' => Str::slug($this->name)]);
return auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'name' => 'required|min:3|max:50',
'slug' => 'required|min:1|unique:meat_types,slug',
'status' => 'required|boolean'
];
}
}