2017-11-12 2 views
-1

私はその後、私は私がユーザーIDに基づいて「USERTABLE」からのデータを表示したいのuserIdを持っているこの5データ内の5個のデータを得たジョブIDに基づいて「jobTable」からのデータと一致したいを使用したデータを検索します。それから私は変数でそれをキャッチし、私は私のビューでそれを表示したい、私はそれをループを使用して表示されます。Laravelフレームワーク

私はコードの下にこれを行う場合、それは私のUSERTABLEからのすべてのデータが一致したジョブIDベースのUserId詳細に基づいて表示されませ示しています。

public function applyUser($jobId){ 

    $applyUsers=ApplyInfo::where('job_id', $jobId)->get(); 
    //5 rows found, with in this 5 rows everybody has userId I want to show data from user table based on this found userId and pass value a variable then i will loop it on view page. 

    foreach ($applyUsers as $applyUser){ 

    $applyUsersDtials=Employee::find($applyUser->user_id)->get(); 

    } 

    return view('front.user.apply-user-details', ['applyUsersDtials'=>$applyUsersDtials]); 
} 

//when i do that that time show all data based on my user table not show based on my JobId 

答えて

0

まず、$applyUsersDtialsは変数であり、配列でなければなりません。次に、1行を見つける必要がある場合は、find()を使用するだけです。今すぐお試しください -

public function applyUser($jobId){ 

    $applyUsers = ApplyInfo::where('job_id', $jobId)->get(); 

    $applyUsersDtials = []; 

    foreach ($applyUsers as $applyUser){ 
     $applyUsersDtials[] = Employee::find($applyUser->user_id); 
    } 

    return view('front.user.apply-user-details', 
       ['applyUsersDtials' => $applyUsersDtials]); 
} 
+0

ありがとうBro @Risul Islamは現在動作しています。要点は、真実を配列として宣言する必要があることです。 –

関連する問題