I need extends ModelTable class to add follow method just one time, and not in each class
public function addOrUpdate($data, $options=[]) {
if ($this->existe($data)) {
$obj = $this->findById($data['id'])->first();
$obj = $this->patchEntity($obj, $data,$options);
}else{
$obj = $this->newEntity($data,$options);
}
return $this->save($obj);
}
You can create an CustomTable class extending Table class. Place your function inside CustomTable class.Then you can create each model table class extending CustomTable class.
class CustomTable extends Table {
public function addOrUpdate($data, $options = [])
{
...
}
}
class ModelTable extends CustomTable {
...
}