Why do you pass DB::raw
to your select()
when all you select are fields? You can pass multiple arguments to select, so your (look how readable well-indented code is):
->select(DB::raw('
notifications.id,
notifications.subject,
notifications.message,
notifications.url,
notifications.start_date,
notifications.end_date,
notifications.access_role_id,
notifications_pivot.id,
notifcations_pivot.notification_id,
notifications_pivot.user_id,
notifications_pivot.is_read
'))
Should be:
->select(
'notifications.id',
'notifications.subject',
'notifications.message',
'notifications.url',
'notifications.start_date',
'notifications.end_date',
'notifications.access_role_id',
'notifications_pivot.id',
'notifcations_pivot.notification_id',
'notifications_pivot.user_id',
'notifications_pivot.is_read'
)
Plus, why do you use closure in join()
if you use it in standard way? Read the docs, man.
My code is beautifully indented in the actual file, it just got all out of whack when I pasted it in here. I tried the select without the raw, but still got an error. Will try it again though as I didn't separate each field as individual parameters.
The closure is what is in the docs, . . . man.
Thanks for the tip. :-)
Okay so I tried
->select(
'notifications.id',
'notifications.subject',
'notifications.message',
'notifications.url',
'notifications.start_date',
'notifications.end_date',
'notifications.access_role_id',
'notifications_pivot.id',
'notifcations_pivot.notification_id',
'notifications_pivot.user_id',
'notifications_pivot.is_read'
)
But I am getting the same error as before. I thought I had already tried this, which is why I switched to the raw usage, but still throwing an error, a totally useless error I might add, but an error nonetheless.
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Method Illuminate\View\View::__toString() must not throw an exception
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community