I have two tables who are related.
settlements:
| id | reon_id | name |
add_members:
| id | settlement_id | first_name | last_name | cipher_id |
In Settlement Model their related like this:
public function members()
{
return $this->hasMany('App\AddMember');
}
So, first I need all members with reon_id of 1, so I did like this:
$members = Settlement::where('reon_id', '1')
->with('members')
->count();
and that works. But now, I need same thing but also with cipher_id of 1. If I add ->where('cipher_id', '1') after ->with('members') I get this error:
(2/2) QueryException SQLSTATE[42S22]: Column not found: 1054 Unknown column 'cipher_id' in 'where clause'
Where I am wrong?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire