2021-11-16 16:00:47 +01:00
|
|
|
<?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.
|
|
|
|
|
*
|
2022-02-10 16:14:58 +01:00
|
|
|
* @return boolean
|
2021-11-16 16:00:47 +01:00
|
|
|
*/
|
|
|
|
|
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 [
|
2021-11-29 09:31:29 +01:00
|
|
|
'name' => 'required|min:3|max:50',
|
2021-11-29 09:37:36 +01:00
|
|
|
'slug' => 'required|min:1|unique:labels,slug',
|
2021-11-16 16:00:47 +01:00
|
|
|
'status' => 'required|boolean'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|