You've already forked pilot-sdk
update README; add Laravel stubs; add form support
This commit is contained in:
47
src/Laravel/Commands/MakeAction.php
Normal file
47
src/Laravel/Commands/MakeAction.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Bluesquare\Pilot\Laravel\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class MakeAction extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'pilot:action {name?}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Generate files for a Bluesquare Pilot action';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$name = $this->hasArgument('name')
|
||||
? $this->argument('name')
|
||||
: $this->ask('What is the name of the action?', 'MakeSmoothie');
|
||||
|
||||
$contents = file_get_contents(__DIR__.'/../stubs/action.php');
|
||||
$contents = str_replace('MakeSmoothie', $name, $contents);
|
||||
$contents = str_replace('make-smoothie', Str::slug($name), $contents);
|
||||
$path = app_path('Pilot/Actions/'.$name.'.php');
|
||||
|
||||
if (file_exists($path)) {
|
||||
$this->error('Action already exists!');
|
||||
return;
|
||||
}
|
||||
|
||||
@mkdir(dirname($path), 0755, true);
|
||||
file_put_contents($path, $contents);
|
||||
$this->info('Action created successfully!');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user