Why use new $this->model() instead of new $this->model ?
kkbox2468 opened this issue · 1 comments
kkbox2468 commented
Discussed in #130
Originally posted by kkbox2468 April 12, 2022
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
.
Did I miss something?
freekmurze commented
Duplicate of discussion