54
common/Generators/Model/GenerateModel.php
Executable file
54
common/Generators/Model/GenerateModel.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace Common\Generators\Model;
|
||||
|
||||
use Illuminate\Foundation\Console\ModelMakeCommand;
|
||||
|
||||
class GenerateModel extends ModelMakeCommand
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$this->input->setOption('resource', true);
|
||||
$this->input->setOption('migration', true);
|
||||
$this->createPolicy();
|
||||
$this->createRequest();
|
||||
$this->createAction();
|
||||
|
||||
parent::handle();
|
||||
}
|
||||
|
||||
protected function createPolicy()
|
||||
{
|
||||
$modelName = $this->getNameInput();
|
||||
|
||||
$this->call('make:policy', [
|
||||
'name' => "{$modelName}Policy",
|
||||
'--model' => $modelName
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getStub()
|
||||
{
|
||||
return __DIR__.'/stubs/model.stub';
|
||||
}
|
||||
|
||||
private function createRequest()
|
||||
{
|
||||
$modelName = $this->getNameInput();
|
||||
|
||||
$this->call('make:request', [
|
||||
'name' => "Crupdate{$modelName}Request",
|
||||
'--model' => $modelName
|
||||
]);
|
||||
}
|
||||
|
||||
private function createAction()
|
||||
{
|
||||
$modelName = $this->getNameInput();
|
||||
|
||||
$this->call('make:action', [
|
||||
'name' => "Crupdate{$modelName}",
|
||||
'--model' => $modelName
|
||||
]);
|
||||
}
|
||||
}
|
||||
26
common/Generators/Model/stubs/model.stub
Executable file
26
common/Generators/Model/stubs/model.stub
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace DummyNamespace;
|
||||
|
||||
use Eloquent;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* DummyNamespace\DummyClass
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class DummyClass extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
|
||||
protected $casts = [
|
||||
'id' => 'integer',
|
||||
'user_id' => 'integer',
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user