Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

had to use first instead of get.

  $leverancier = DB::table('leveranciers')
                    ->where('leveranciersId', '=', $id)
                    ->join('plaatsen', 'leveranciers.plaatsId', '=', 'plaatsen.plaatsId')
                    ->first();
Last updated 8 years ago.
0

I recommend using the join clause before the where clause

Also, if you have a one to many relationship, you should use get instead of first.

  $leverancier = DB::table('leveranciers')
                    ->where('leveranciersId', '=', $id)
                    ->join('plaatsen', 'leveranciers.plaatsId', '=', 'plaatsen.plaatsId')
					->get([
						'leveranciers.field1 AS f1',
						'leveranciers.field2 AS f2,
						'plaatsen.field1 AS f3,
						'plaatsen.field2 AS f4'
					])
                    ->first();

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.