Reputation: 349
I am currently working on a school project and am trying to retrieve values from a successfully ran query. The query is as so:
$airportQuery = Airport::where('id', '=', $airport)->get(); //Returns all columns of users selected airportId
I am trying to retrieve a column "extendedcenterlineLong" and "extendedcenterlineLat". I am doing this by running
array[] = $airportQuery->extendedcenterLong;
array[] = $airportQuery->extendedcenterLat;
(The array isn't named array[] either) When I try to run myQuery I get this error
I have not been able to fix this issue, what am I doing wrong? Many Thanks!
EDIT: I also have these queries to get the previous row or next row from waht the user selects
$previous = Airport::where('id', '<', $airport)->max('id'); //Returns the previous rows values from users current selected airportId
$next = Airport::where('id', '>', $airport)->min('id'); //Returns the next rows values from users current selected airportId
EDIT: I solved the problem by doing $airportQuery->first()->column_name
. For some reason when I printed out $airportQuery there were two items that were arrays of the column info that were identical to each other, a copy basically.
Upvotes: 1
Views: 88
Reputation: 646
You can just do a
$airportQuery = Airport::where('id', '=', $airport)->first();
i guess above should work.
Upvotes: 2