希望你們中的一位能幫助我解決問題。我收到一個錯誤,告訴我我沒有在 in_array() 中使用數(shù)組。使用 pluck() 應(yīng)該會給我一個數(shù)組,對吧?{{ Request::ip() }}{{ $pug->ipbans->pluck('ip') }}Output:127.0.0.1["127.0.0.1","127.0.0.1"]然后在刀片中:@if( in_array( Request::ip(), $pug->ipbans->pluck('ip') ) ) <div class="alert alert-danger"> Your IP has been blocked on this page. Changes not allowed. </div>@endif我收到以下錯誤:in_array() expects parameter 2 to be array, object given (View: ...)所以它告訴我這$pug->ipbans->pluck('ip')不是一個數(shù)組 - 但它是,對嗎?
3 回答
有只小跳蛙
TA貢獻(xiàn)1824條經(jīng)驗 獲得超8個贊
集合方法“pluck”返回集合而不是數(shù)組
要使結(jié)果成為數(shù)組,您可以使用“all”:
{{?$pug->ipbans->pluck('ip')->all()?}}- 3 回答
- 0 關(guān)注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消
