lev_
lev_

Reputation: 29

how to pass the query result to the view? Laravel

I can not get the result of such a request:

$performance = DB::select("SELECT ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60) FROM tickets WHERE id = ?", [$id]);

the result comes in the form of an array:

array:1 [
 0 => {#1385 
  +"ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60)": "299"
 }
]

Upvotes: 0

Views: 303

Answers (1)

Nima Tf
Nima Tf

Reputation: 71

Thats becouse your not included get() in end of your code. Replace this:

$performance = DB::select("SELECT ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60) FROM tickets WHERE id = ?", [$id])->get();

with this:

$performance = DB::select("SELECT ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60) FROM tickets WHERE id = ?", [$id]);

Upvotes: 2

Related Questions