37 lines
818 B
PHP
37 lines
818 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 boolean
|
|
*/
|
|
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:labels,slug',
|
|
'status' => 'required|boolean'
|
|
];
|
|
}
|
|
}
|