Ben tek kontroller için tek FormRequest kullanıyorum daha düzenli oluyor
class UserRequest extends ApiRequest
{
public const PARAMETER = 'user';
public function rulesIndex()
{
return UserFilter::rules();
}
public function rulesStore()
{
return [
User::COLUMN['NAME'] => [
'required',
'string',
Rule::unique(User::TABLE, User::COLUMN['NAME']),
'min:3',
],
User::COLUMN['EMAIL'] => [
'required',
'email',
Rule::unique(User::TABLE, User::COLUMN['EMAIL']),
],
User::COLUMN['PASSWORD'] => [
'required',
'string',
'min:5',
]
];
}
public function rulesShow()
{
return [
];
}
public function rulesUpdate()
{
return [
User::COLUMN['NAME'] => [
'string',
Rule::unique(User::TABLE, User::COLUMN['NAME'])
->ignore($this->parameter()),
'min:3',
],
User::COLUMN['EMAIL'] => [
'email',
Rule::unique(User::TABLE, User::COLUMN['EMAIL'])
->ignore($this->parameter()),
],
User::COLUMN['PASSWORD'] => [
'string',
'min:5',
]
];
}
public function rulesDestroy()
{
return [
];
}
}