我的Javascript中有以下一行
#!/bin/bash
array=(*) # this is the array of files to shuffle
# echo ${array[@]}
for dummy in "${array[@]}"; do # do loop length(array) times; once for each file
length=${#array[@]}
randomi=$(( $RANDOM % $length )) # select a random index
filename=${array[$randomi]}
echo "Processing: '$filename'" # do something with the file
unset -v "array[$randomi]" # set the element at index $randomi to NULL
array=("${array[@]}") # remove NULL elements introduced by unset; copy array
done
现在,如果我未经过身份验证,此行会抛出错误
let roles = {!! Auth::user()->roles()->get() !!};
虽然我只是想重定向到/ login页面!
有人能告诉我怎么做吗?在控制器中执行此操作没有问题,但在页面本身上我尝试了像
这样的Blade命令Call to a member function roles() on null (View: D:\data\Project\resources\views\booking.blade.php)
... @endif
但没有成功!
答案 0 :(得分:1)
您可以尝试以下操作:
let roles = {!! Auth::user() ? Auth::user()->roles()->get() : '' !!};