<?php

namespace Yajny\EventsYj\Commands;

use Illuminate\Console\GeneratorCommand;
use Illuminate\Support\Str;

class EventYjMakeCommand extends GeneratorCommand
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'make:eventYj';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Create a new event class';

    /**
     * The type of class being generated.
     *
     * @var string
     */
    protected $type = 'Event';

    /**
     * Determine if the class already exists.
     *
     * @param  string  $rawName
     * @return bool
     */
    protected function alreadyExists($rawName)
    {
        return class_exists($rawName);
    }

     /**
     * Replace the namespace for the given stub.
     *
     * @param  string  $stub
     * @param  string  $name
     * @return $this
     */
    protected function replaceNamespace(&$stub, $name)
    {
        $stub = str_replace(
            ['DummyNamespace', 'DummyRootNamespace', 'NamespacedDummyUserModel'],
            ['Yajny\EventsYj\Events', $this->rootNamespace(), $this->userProviderModel()],
            $stub
        );     
        return $this;
    }

    

    /**
     * Get the stub file for the generator.
     *
     * @return string
     */   

    protected function getStub()
    {
        return __DIR__.'/stubs/eventYj.stub';
    }

     /**
     * Get the destination class path.
     *
     * @param  string  $name
     * @return string
     */
    protected function getPath($name)
    {
      
        $name = Str::replaceFirst($this->rootNamespace(), '', $name);        

         return  $this->laravel['path'].'/../vendor/yajny/eventsyj/src/Events/'.str_replace('\\', '/', $name).'.php';
        
    }

   
}
