Level 75
@alyve You can do something like from this thread
https://stackoverflow.com/a/42674302
Or maybe you can use this package
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I'm looking for a way to set authorization to update only a selection on field. For example, a thread can't be updated by a user.
I tried to create a new rule and add it to a request like this:
The rule:
public function passes($attribute, $value)
{
return Auth::user()->isModeratorOrAdmin();
}
The FormRequest:
public function rules()
{
return [
'title' => 'required|min:3|max:140',
'category_id' => 'required|exists:categories,id',
'content' => [
'required',
Rule::requiredIf(function () {
dd($this->route('threads.store'));
})
],
'pinned' => [
'optional',
new OnlyStaffRule(),
]
];
}
It doesn't work and I don't find any way to perform this operation. Maybe someone can help me, please ?
Thank you.
Alyve
@alyve You can do something like from this thread
https://stackoverflow.com/a/42674302
Or maybe you can use this package
Please or to participate in this conversation.