vendredi 19 octobre 2018

Can not extend class in laravel in depandancy injection

I have one repository which belongs to a package and it is PageRepository I have extended this repository to replace may Laravel model

namespace App\Repositories;

use App\Page;
use App\Repositories\TranslationRepository;
use Grafite\Cms\Repositories\PageRepository as GrafitePageRepository;

/**
 * Extend Grafite PageRepository
 */
class PageRepository extends GrafitePageRepository {
    public function __construct() {
        parent::__construct();
        $this->model           = $model;
        $this->translationRepo = $translationRepo;
        $this->table           = config('cms.db-prefix').'pages';
    }
}

Now in controller construct method when I dd($repository) it shows me it is an object of App\Repository\PageRepository which is correct but the property $translationRepo is an object of Grafite\Cms\Repositories\TranslationRepository it should be App\Repository\TranlationRepository

PS: I have also extended TranlationRepository to replace my App Translation model



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire