Support the ongoing development of Laravel.io →
posted 9 years ago
Database
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

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. :-)

Last updated 2 years ago.
0

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
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.