src/Console/Commands/MakeApiResource.php
/**
     * Execute the console command.
     *
     * @return mixed
     */
Execute the console command.
@return mixed
Execute the console command . @return mixed
public function handle(): void
    {
        $name = $this->argument('name');
        $resource = new Resource($name);
        $resourceFileTypes = config('api-resource-generator.types');
        foreach ($resourceFileTypes as $type) {
            $name = "\\Firevel\\ApiResourceGenerator\\Factories\\Resource{$type}FileFactory";
            ($name)::handle($resource);
            $this->info("{$resource->singularPascal()} {$type} created.");
        }
        $this->info("\n");
        $this->info('To do:');
        $this->info("1. Setup migration database/migrations/create_{$resource->pluralSnake()}_table.php");
        $this->info("2. Setup \$fillables in app/Models/{$resource->singularPascal()}.php");
        $this->info("3. Setup the transformer at app/Transformers/{$resource->singularPascal()}Transformer.php");
        $this->info("4. Setup permissions in app/Policies/{$resource->singularPascal()}Policy::class");
        $this->info("5. Register the policy: {$resource->singularPascal()}::class => {$resource->singularPascal()}Policy::class.");
        $this->info("6. Register the API route: Route::apiResource('{$resource->pluralSnake()}', '{$resource->pluralPascal()}Controller');.");
        $this->info("\n");
        $this->info('Optional:');
        $this->info("- Setup factory at database/factories/{$resource->singularPascal()}Factory.php");
        $this->info("- Setup seeder at database/seeds/{$resource->pluralPascal()}Seeder.php");
        $this->info("- Add {$resource->pluralPascal()}Seeder.php to database/seeds/DatabaseSeeder.php.");
        $this->info("- Setup validation at Http/Requests/{$resource->singularPascal()}");
        $this->info("- Setup unit tests at tests/Feature/{$resource->singularPascal()}");
    }
public function handle ( ) : void { $ name = $ this -> argument ( 'name' ) ; $ resource = new Resource ( $ name ) ; $ resourceFileTypes = config ( 'api-resource-generator.types' ) ; foreach ( $ resourceFileTypes as $ type ) { $ name = " \\ Firevel \\ ApiResourceGenerator \\ Factories \\ Resource { $ type } FileFactory " ; ( $ name ) :: handle ( $ resource ) ; $ this -> info ( " { $ resource -> singularPascal ( ) } { $ type }  created. " ) ; } $ this -> info ( " \n " ) ; $ this -> info ( 'To do:' ) ; $ this -> info ( " 1. Setup migration database/migrations/create_ { $ resource -> pluralSnake ( ) } _table.php " ) ; $ this -> info ( " 2. Setup  \$ fillables in app/Models/ { $ resource -> singularPascal ( ) } .php " ) ; $ this -> info ( " 3. Setup the transformer at app/Transformers/ { $ resource -> singularPascal ( ) } Transformer.php " ) ; $ this -> info ( " 4. Setup permissions in app/Policies/ { $ resource -> singularPascal ( ) } Policy::class " ) ; $ this -> info ( " 5. Register the policy:  { $ resource -> singularPascal ( ) } ::class =>  { $ resource -> singularPascal ( ) } Policy::class. " ) ; $ this -> info ( " 6. Register the API route: Route::apiResource(' { $ resource -> pluralSnake ( ) } ', ' { $ resource -> pluralPascal ( ) } Controller');. " ) ; $ this -> info ( " \n " ) ; $ this -> info ( 'Optional:' ) ; $ this -> info ( " - Setup factory at database/factories/ { $ resource -> singularPascal ( ) } Factory.php " ) ; $ this -> info ( " - Setup seeder at database/seeds/ { $ resource -> pluralPascal ( ) } Seeder.php " ) ; $ this -> info ( " - Add  { $ resource -> pluralPascal ( ) } Seeder.php to database/seeds/DatabaseSeeder.php. " ) ; $ this -> info ( " - Setup validation at Http/Requests/ { $ resource -> singularPascal ( ) } " ) ; $ this -> info ( " - Setup unit tests at tests/Feature/ { $ resource -> singularPascal ( ) } " ) ; }
Execute the console command.
Execute the console command .