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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -