2017-05-05 10 views
2
public function contactDetail($user_id){ 
     // dd($user_id); 
     $details = User::get(['id','first_name','last_name','mobile_no'])->where('id',$user_id)->first(); 
     dd($details); 
     return View::make('ContactDetail')->with('data',$details); 
    } 

$user_id保存された値は$details DBからヌルになります。 $user_idではなく静的な値をDBから取得する場合DBのIDからnullを取得すると、LaravelのDBに存在します。

答えて

0
にクエリを変更し

:あなたはget()前にどこを呼び出している

$details = DB::table('users') 
       ->select('id','first_name','last_name','mobile_no') 
       ->where('id',$user_id) 
       ->first(); 

、これが問題の原因である必要があります。

+0

はい、ありがとうございます。 'where()'の後に 'get()'を使う必要があります。 –

+0

ニース!それがあなたのために働いた場合、答えを受け入れることができますか?ありがとうございました! – Laerte

+1

3分後。 –

関連する問題