You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello
I am dissecting some code and came across this,
public function getType(): string
{
$model = new $this->model();
if (property_exists($model, 'searchableType')) {
return $model->searchableType;
}
return $model->getTable();
}
in laravel-searchable/src/ModelSearchAspect.php
As far as I know, instance of ModelSearchAspect doesn’t have model method, so __call function will be executed, but not actually executed.
Actually new $this->model() is equivalent to new $this->model, so i don’t know why use new $this->model() instead of new $this->model.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello
I am dissecting some code and came across this,
in laravel-searchable/src/ModelSearchAspect.php
As far as I know, instance of ModelSearchAspect doesn’t have
model
method, so__call
function will be executed, but not actually executed.Actually
new $this->model()
is equivalent tonew $this->model
, so i don’t know why usenew $this->model()
instead ofnew $this->model
.Did I miss something?
Beta Was this translation helpful? Give feedback.
All reactions