2016-06-01 6 views
0

これは簡単ですが、falseに解決されているにもかかわらず、私のifブロック内のコードが実行されていて、非常に不快になっています...このuser_idは2です。Laravel 5単純比較が失敗する

$note = Notification::where("user_id",Auth::user()->id)->first(); 
$wall = $note->pluck('wall'); 
if($wall != 0) 
{ 
//This code is executing! 
} 
else{ 
    array_push($data,"Your First Time!"); 
    //This code is not! 
} 

あなたが見ることができるように、私の$壁はなぜ$wall != 0実行ので、私は理解していない、ゼロでなければなりません。

enter image description here

+0

はあなたが '0' '確かにwall'です$よろしいです削除しますか? 'if(..){..'の前に' var_dump($ wall); 'を実行してみてください。 – Darren

+0

私はあなたが引き金を使う必要はないと思います。 - > first()を使用してモデルを取得しています。単純に$ note-> wall @を実行してください。 – Brett

+0

@Darrenありがとう、それは私に 'string(3)" 130 "'を与えました。何らかの理由でそれが間違った 'user_id'から読み込んでいます... –

答えて

2

は摘む

$note = Notification::where("user_id",Auth::user()->id)->first(); 
$wall = $note->wall; //This changed 
if($wall != 0) 
{ 
//This code is executing! 
} 
else{ 
    array_push($data,"Your First Time!"); 
    //This code is not! 
} 
関連する問題