for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Spatie\ViewModels\Console;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
class ViewModelMakeCommand extends GeneratorCommand
{
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:view-model';
* The console command description.
protected $description = 'Create a new ViewModel class';
* The type of class being generated.
protected $type = 'ViewModel';
* Execute the console command.
* @return void
public function handle()
if (parent::handle() === false && ! $this->option('force')) {
return;
}
* Get the stub file for the generator.
* @return string
protected function getStub()
return __DIR__.'/../../stubs/DummyViewModel.stub';
* Get the console command options.
* @return array
protected function getOptions(): array
return [
['force', null, InputOption::VALUE_NONE, 'Create the class even if the view-model already exists'],
];