我想在<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
答案 0 :(得分:0)
与specified in their docs一样,您可以简单地使用#Flatten:
shape = tensor.shape
tensor_reshaped = tensor.reshape(shape[0],-1)
#Drop all rows containing any nan:
tensor_reshaped = tensor_reshaped[~torch.any(tensor_reshaped.isnan(),dim=1)]
#Reshape back:
tensor = tensor_reshaped.reshape(tensor_reshaped.shape[0],*shape[1:])
来获得具有特定角色的所有用户。
User::role('role_name')->get()
请注意,您应该从控制器本身进行这种状态检查,并将$ doctors列表传递给刀片服务器