dimanche 2 septembre 2018

send a selected field to with function

how can i use "airpot_id" in with function?

    City::select([
                "cities.id",
                "airports.id As airport_id"
            ])
  ->RightJoin('airports', function ($join)
                {
                    $join->on('cities.id', '=', 'airports.city_id');
                })
->with(["airports" =>  function  ($q)
                {
                    $q->where("id",airport_id) //I want to use here.

                }]) 
->paginate(env("PER_PAGE", 10))->toArray();



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire