Raw Sql-select

Posted 10 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 COUNT(*)
                             FROM appointments
                             WHERE p ='x'
                             AND =
                             GROUP BY A_id
                             ) as fp,

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

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

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up


Reply to

Use Markdown with GitHub-flavored code blocks.