38 lines
819 B
PHP
38 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:5|max:50',
|
||
|
|
'slug' => 'required|min:1|unique:meat_types,slug',
|
||
|
|
'status' => 'required|boolean'
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|