vendredi 27 octobre 2017

Extending laravel's SeedCommand

Trying to make an extension to the core db:seed command to add a couple of necessary options. Extending the Illuminate\Database\Console\Seeds\SeedCommand and registering my command in Kernel.php give me following output when running php artisan :

[Illuminate\Contracts\Container\BindingResolutionException]
Target [Illuminate\Database\ConnectionResolverInterface] is not instantiable while building [App\Console\Commands\TenantSeeder].

Any hints what I am missing ? the class itself below :

<?php

namespace App\Console\Commands;

use Illuminate\Database\Console\Seeds\SeedCommand;
use Illuminate\Console\ConfirmableTrait;
use Symfony\Component\Console\Input\InputOption;
use Illuminate\Database\ConnectionResolverInterface as Resolver;

class TenantSeeder extends SeedCommand
{
    use ConfirmableTrait;
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'tenant:seed';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * The connection resolver instance.
     *
     * @var \Illuminate\Database\ConnectionResolverInterface
     */
    protected $resolver;

    /**
     * Create a new database seed command instance.
     *
     * @param  \Illuminate\Database\ConnectionResolverInterface  $resolver
     * @return void
     */
    public function __construct(Resolver $resolver)
    {
        parent::__construct();

        $this->resolver = $resolver;
    }

    public function getOptions()
    {
        $opts = parent::getOptions();
        return array_merge($opts, [
            ['tenant', null, InputOption::VALUE_REQUIRED, 'Tenant is required to generate tenant-specific data'],
        ]);
    }
}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iDLVLQ
via IFTTT

Aucun commentaire:

Enregistrer un commentaire