vendredi 18 mars 2016

Laravel Query not returning any data

I have a database table 'mileages' which contains 3 columns :

start_location 
end_location
miles

My query is built using a scope selector in my Mileage model (start_location and end_location are getting passed in appropriately):

//Get miles for the start_location -> end_location

public function scopeMileageDistance($query)
{
    $query->where('start_location', '=', 'start_location')->where('end_location', '=', 'end_location')->get();
}

I'm accessing it in my Controller:

$distance = Mileage::MileageDistance()->get();

When I dumpordie:

dd($distance);

It shows as returning nothing. But if I run this SQL query on the database - it gets back the appropriate object:

select * from mileages where start_location = 'pointA' and end_location = 'pointB'

Just wondering if I'm doing something wrong with my scope selector and/or query.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire