【发布时间】:2025-12-26 09:55:12
【问题描述】:
我想在 <select> 中列出所有具有特定角色 doctor 的用户,我正在使用 laravel spatie 库
<label for="select_doctor">{{__("Select doctor") }}</label>
<select name="select_doctor" id="select_doctor" class="form-control">
<option value="" selected disabled>----- * ----</option>
@foreach (App\User::all()->hasRole('doctor') as $doctor)
<option value="">{{ __($doctor->person->name) }}</option>
@endforeach
</select>
但我收到此错误
Method Illuminate\Database\Eloquent\Collection::hasRole does not exist
【问题讨论】:
标签: laravel laravel-permission