dimanche 1 juillet 2018

Laravel Query with Multiple Tables Join and Multiple Join Fields

I'm trying to build a query to join multiple tables with multiple join fields.

This is the code:

        $crew = DB::table('crew')
            ->join('aclist', function ($join){
                $join->on(function($query){
                  $query->on('aclist.ac_config', '=', 'crew.config')
                        ->on('aclist.ac_type', '=', 'crew.ac_type');
                });
            })
            // Error happened after I add this indexform join script
            ->join('indexform', function ($join){
                $join->on(function($query){
                $query->on('indexform.config', '=', 'crew.config')
                       ->on('indexform.ac_type', '=', 'crew.ac_type');
                });
            })        

            ->select('crew.*','indexform.*')
            ->where('aclist.ac_reg', $input['acreg'])
            ->get();

The query work well before I add the script to join the indexform tables. Please help how to build query to join three tables with multiple "on" criteria.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire