I have a users table and a positions table and they have relationship in my Model.
User model
class User extends Eloquent {
public function position()
{
return $this->belongsTo('Position');
}
}
Position model
class Position extends Eloquent {
public function users()
{
return $this->hasMany('User');
}
}
I try to do this.
$users = User::find(1);
echo $users->lastname . "<br>"; // output the lastname
echo $users->position->name . "<br>"; // output the position name
echo $users->toSql(); // output "Select * from user"
My question is how can I get the generated raw SQL? something like
select s.* from users s left join positions p on p.id = s.position_id where s.id = 1
Im using Eloquent standalone. Thank you in advance.