plutarcomp
10 months ago

Pass variables from controller to model

Posted 10 months ago by plutarcomp

I need to pass three varables i get in my controller via API and pass it to a model that need to search some criteria.

This is my controller

public function getTours($lat,$long,$dist)
    {
      $todas = Tour::select('id')->where('status',1)->with('conlocalizacion')->get();
      return $todas;
    }

i need to pass to model 'conlocalizacion' three variables to process a search in that.

This is my model

public function conlocalizacion()
    {
      return $this->hasMany('App\ToursEstacione')
                 ->whereBetween('latitude',[($lat - ($dist*0.014)),($lat + ($dist*0.014))])
         ->whereBetween('longitude',[($long - ($dist*0.014)),($long + ($dist*0.014))]);
    }

i try to use with(), but nothing happend.

Thanks

Please sign in or create an account to participate in this conversation.