SELECT users.fname, planets.name
FROM users
LEFT JOIN planets ON (users.planet_id = planets.id)
WHERE users.lname LIKE '%hawk%'
ELOQUENT SQL:
$name = "hawk";
$userResults = DB::table('users')
->leftJoin('planets', function($join) {
$join->on('users.planet_id', '=' , 'planets.id');
})
->where('users.lname' , 'like', '%'.$name.'%')
->get(array('users.fname', 'planets.name'));
Is this eloquent or query builder?
ReplyDeleteCheck https://laravel.com/docs/5.1/queries#joins
Clearly this is NOT Eloquent. Eloquent is Laravel's Model, ActiveRecord. If you start the code with DB, then it's just the Query Builder.
ReplyDeleteuse Wherehas ORM
ReplyDelete