php - how to extend the get() method in eloquent -
how extend method get()
in eloquent class, add code join whenever called.
whenever method all()
, find or get()
called, add join:
static::join('clientes', 'clientes.id', '=', 'faturas.cliente_id');
thanks
have tried eager loading? can set protected $with = array('clients');
in model.
you overload newquery
method extending model class.
class basemodel extends model { public function newquery($excludedeleted = true) { $builder = parent::newquery($excludedeleted); $builder->join('clientes', 'clientes.id', '=', 'faturas.cliente_id'); return $builder; } }
Comments
Post a Comment