lundi 26 novembre 2018

How to use query builder to retrieve array values from different tables?

Following is the code snippet that I have used in my controller:

 public function index(Request $request)
    { 
        $query = DB::table('project_files')->select('project_id')->get()->toArray();
        dd($query);
        return view ( 'filesync/listfiles' )->with ( $query);
    }

So when I try passing the values into the view, I get an array which consists of the project_id from the project_files table. What I would want to do now is to retrieve the project_names of these project_ids, stored in the projects table.I need to use the project_id for the same , but am unable to understand how to relate these using query builder.Any help would be appreciated, meaning how do I use the array values in the query retrieving project names from projects table.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire