jeudi 3 décembre 2015

Laravel 5.1: query builder relations

After looking around for solutions I finally created a workaround.

Using the query builder I create a get the results like this:

$terminal = Terminal::where(function($q) use ($username,$password) {
                    $q->where('active','=',1);
                    $q->where('user','=',$username);
                    $q->where('password','=',$password);
                    $q->take(1);
                    })->get();

And to use the ID:

$terminal = Terminal::findorfail($terminal[0]['id']);

Using the ID for Eloquent

$username = $terminal->locations->issuers->username;
$password = $terminal->locations->issuers->password;

I need to get the relations, but using query builder I couldn't get any further.

I know this is a dirty solution and would like some help how to change it so it's less dirty.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire