if I got an array like $tags = ['first', 'second', 'etc']
how do I select all instances of model from database where one of the columns only holds one of values found in the array above.
How would my where look? How do I loop through the array and construc the correct query so I do not miss any objects?
Querently I have decided to place it inside a local scope
public function scopeTriptags($query, $triptags) {
foreach ($triptags as $triptag) {
$query->where()
}
}
I am not sure if I can just chain them using where? if I should use orWhere will that work correctly if orWhere is used in the first loop?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire