Published 4 months ago by mlutz
i have a problem with a raw SQL-select. This Code works in Laravel 5.2:
$massage = DB::table('course') ->select(DB::raw("*, (SELECT COUNT(*) FROM appointments WHERE p ='x' AND appointments.id = course.id GROUP BY A_id ) as fp, ... ... "))->get();
I've got a value for the the variable "fp".
With Laravel 5.5 the value "fp" is empty.
With the raw-select the get and set attributes in the model doesn't work, too.
For a better understanding: I have a table with sport courses. The table course has a many relation to the table appointments. I need the count of the booked appointments.
How can i solve my problem?
Best regards Markus
Thanks for your reply. I tested the "selectRaw". The query received a value. So the first step works. :)
But the next problem is the date format. The get attribute in the model seems to be ignored. The date format is wrong. Am i right, the the attribute works only with eloquent?