view examples/ExampleGenerator.php.stub @ 3:6468684362c2

It works! Created a controller, no update insert but it works
author luka
date Tue, 27 Jun 2023 15:32:47 -0400
parents cf9993c5c7df
children a20439b1c9d3
line wrap: on
line source

<?php

namespace App\Console\Commands;

use Symfony\Component\Console\Attribute\AsCommand;
use Wizzard\MagicForger\Generator\BaseGenerator;
use Wizzard\MagicForger\Replacer;
//use Illuminate\Console\Concerns\CreatesMatchingTest;

#[AsCommand(name: 'mf:{{ Command Name }}')]
class {{ Class Name }}Generator extends BaseGenerator
{
    //use CreatesMatchingTest;

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $name = 'mf:{{ Command Name }}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generates the {{ Class Name }} File for a table.';

    /**
     * The type of class being generated.
     *
     * @var string
     */
    protected $type = '{{ Class Name }}';


    /**
     * Execute the console command.
     */
    public function handle()
    {
			parent::handle();
    }

    /**
     * Get the stub file for the generator.
     *
     * @return string
     */
    protected function getStub()
    {
        return $this->resolveStubPath('/stubs/seeder.stub');
    }

    /**
     * Resolve the fully-qualified path to the stub.
     *
     * @param  string  $stub
     * @return string
     */
    protected function resolveStubPath($stub)
    {
        return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
            ? $customPath
            : __DIR__.$stub;
    }
    /**
     * Parse the class name and format according to the root namespace.
     *
     * @param  string  $name
     * @return string
     */
    protected function qualifyClass($name)
    {
        $name = ltrim($name, '\\/');

        $name = str_replace('/', '\\', $name);

        $rootNamespace = $this->rootNamespace();

        if (Str::startsWith($name, $rootNamespace)) {
            return $name;
        }

        return $this->qualifyClass(
            $this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name
        );
    }
}