lundi 26 octobre 2015

Laravel5 Eloquent select from multiple table with where clause

How to do this query in Laravel Eloquent?

SELECT * FROM `ftm_users`, `ftm_students`, `ftm_user_verification` WHERE `ftm_users`.`user_group` = 3 AND `ftm_user_verification`.`verification_status` = 1 AND `ftm_users`.`uid` = `ftm_students`.`uid` AND `ftm_users`.`uid` = `ftm_user_verification`.`uid`

I already set the relationship in Model and I have tried with this

$userStudent = User::where('user_group', '=', 3)->with(array('userVerification' => function($query) {
        $query->where('verification_status', '=', 1);
    }, 'student', 'studentParents'))->simplePaginate(20);

but the query is using separated select statement to get data from different table.

Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire