Closed Zzombiee2361 closed 2 years ago
You have access to the underlying QueryBuilder so you should be able to do:
trait StatusFilter {
public function status($status) {
$table = $this->query->getModel()->getTable();
$this->where("{$table}.status", $status);
}
}
Ah I didn't know about the getModel()
method. And I could use get_class()
if I really need the class
I need the model class in my filter class to get the table name. For example I have multiple table with similar
status
column, so I make aStatusFilter
trait to all filter class that need to filter status. This would be fine unless I join a table also with status column in it, so for that case I need to include the table name.