I am studying a friend's project and I'm confused why he use parent::__construct($model)
and $this->model = $model
at the same time in CategoryRepository.php. Could someone help me understand what's the difference of the two please?
I've already been to these links PHP Codeigniter - parent::__construct, A __construct on an Eloquent Laravel Model but I want a more specific answer correlating to the code below.
Here is the code of CategoryRepository.php
class CategoryRepository extends BaseRepository implements CategoryContract
{
public function __construct(Category $model)
{
parent::__construct($model);
$this->model = $model;
}
}
BaseRepository.php
class BaseRepository implements BaseContract
{
protected $model;
public function __construct(Model $model)
{
$this->model = $model;
}
}