I am making an implementation of a plugin, but I need to obtain the current model that laravel is using when performing some operation ... Is there a function or way to "intercept" the model that Eloquent is working on at that moment?
I am making an implementation of a plugin, but I need to obtain the current model that laravel is using when performing some operation ... Is there a function or way to "intercept" the model that Eloquent is working on at that moment?
What you can do is add a function in all the models that give you the name of the model
class ModeloA extends Model
{
public function mostrarModelo() {
echo 'ModeloA';
}
}
class ModeloB extends Model
{
public function mostrarModelo() {
echo 'ModeloB';
}
}
and how much you have the variable
to return the model you use
$elto=ModeloA::find(1);
$modelo=$elto->mostrarModelo();