Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

daniilgorokh's avatar

Display and saving form for different user’s roles

I have a web form with many fields (about 20) for filling. Admin can view and edit all fields. Managers can view 15 fields and can edit 10 of them.

How can i disable necessary fields for managers in blade template? Do i have to create 20 permissions and check every field?

@can ('edit_name')
    {!! Form::text('name') !!}
@else
    {!! Form::text('name', ['disabled' => 'disabled']) !!}
@endif

And the second question. How can i check, that manager didn’t post restricted fields in request? I see one way: check user’s role and fill each field, because i can’t change property $fillable in my model

if ($isAdmin) {
  $record->name = $request->get('name');
  $record->date = $request->get('date');
  ...
} elseif ($isManager) {
  $record->name = $request->get('name');
  $record->otherField = $request->get('otherField');
  ...
}

Is it right? Can you develop forms like this?

0 likes
0 replies

Please or to participate in this conversation.