Skip to content

Instantly share code, notes, and snippets.

@AnandPilania
Created February 13, 2021 16:15
Show Gist options
  • Save AnandPilania/9d7f34da746184a3ca1617bc890be473 to your computer and use it in GitHub Desktop.
Save AnandPilania/9d7f34da746184a3ca1617bc890be473 to your computer and use it in GitHub Desktop.
Easily create your own scaffold via Laravel Command; example: generate `Traits`
<?php
namespace {{ namespace }};
trait {{ class }}
{}
<?php
namespace App\Console\Commands;
use Illuminate\Console\GeneratorCommand;
class TraitMakeCommand extends GeneratorCommand
{
protected $name = 'make:trait';
protected $type = 'Trait';
protected $description = 'Make Traits';
protected function getStub()
{
return __DIR__ . '/stubs/trait.stub';
}
protected function getNameInput()
{
return trim('Traits\\' . $this->argument('name'));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment