mardi 1 mars 2016

ErrorException in Controller Argument 2 passed to Controller::__construct()

I am getting this error in my laravel application I am not able to find a fix

ErrorException in FactoryController.php line 39:
Argument 2 passed to Vanguard\Http\Controllers\FactoryController::__construct() 
must implement interface Vanguard\Repositories\Factory\FactoryRepository, 
instance of Vanguard\Repositories\Country\EloquentCountry given

These are the lines that it is pointing to.

//Line 39 is below
public function __construct(CountryRepository $countries, FactoryRepository $factories, RoleRepository $roles, PermissionRepository $permissions)
{
    $this->middleware('permission:system.manage');
    $this->roles = $roles;
    $this->permissions = $permissions;
    $this->countries = $countries;
    $this->factories = $factories;

}

This is the code of FactoriesRepositories

   <?php

namespace Vanguard\Repositories\Factory;

interface FactoryRepository
{
    /**
     * Get all system factorys.
     *
     * @return mixed
     */
    public function all();

    /**
     * Finds the factory by given id.
     *
     * @param $id
     * @return mixed
     */
    public function find($id);

    /**
     * Creates new factory from provided data.
     *
     * @param array $data
     * @return mixed
     */
    public function create(array $data);

    /**
     * Updates specified factory.
     *
     * @param $id
     * @param array $data
     * @return mixed
     */
    public function update($id, array $data);

    /**
     * Remove specified factory from repository.
     *
     * @param $id
     * @return mixed
     */
    public function delete($id);
}

and this is the EloquentFactory

<?php

namespace Vanguard\Repositories\Factory;



use Cache;
use Vanguard\Events\Factory\Created;
use Vanguard\Events\Factory\Deleted;
use Vanguard\Events\Permission\Updated;
use Vanguard\Factories;

class EloquentFactory implements FactoryRepository
{
    /**
     * {@inheritdoc}
     */
    public function all()
    {
        return Factories::all();
    }

    /**
     * {@inheritdoc}
     */
    public function find($id)
    {
        return Factories::find($id);
    }

    /**
     * {@inheritdoc}
     */
    public function create(array $data)
    {
        $factory = Factories::create($data);

        event(new Created($factory));

        return $factory;
    }

    /**
     * {@inheritdoc}
     */
    public function update($id, array $data)
    {
        $factory = $this->find($id);

        $factory->update($data);

        Cache::flush();

        event(new Updated($factory));

        return $factory;
    }

    /**
     * {@inheritdoc}
     */
    public function delete($id)
    {
        $factory = $this->find($id);

        event(new Deleted($factory));

        $status = $factory->delete();

        Cache::flush();

        return $status;
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire