в общем есть
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class DeskStoreRequest 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|max:255|unique:desks,name'
];
/*ПРЕДЛОЖИЛИ ТАКОЙ ВАРИАНТ Т.Е КРОМЕ ТЕКУЩЕЙ desk , НО ТОГДА ЭТОТ КОД НЕ ДАЕТ СОЗДАТЬ ТАК КАК ID ПОКА ЕЩЕ НЕТ*/
return [
'name' => 'required|max:255|unique:desks,name,'.$this->desk->id
];
}
public function messages() {
return [
'name.unique' => 'Имя доски должно быть уникальным.'
];
}
}