MakeCRUDGeneratorCommand   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 22 4
A __construct() 0 3 1
1
<?php
2
3
namespace Pratiksh\Adminetic\Console\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\Artisan;
7
use Pratiksh\Adminetic\Services\CRUDGeneratorService;
8
9
class MakeCRUDGeneratorCommand extends Command
10
{
11
    /**
12
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $signature = 'make:crud {name : Model Class (singular) e.g User} {--acl : Make Access Control System for the crud} {--api : Make API Resource of CRUD} {--rest : Make Restful API Resource of CRUD}';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Command to create CRUD.';
24
25
    /**
26
     * Create a new command instance.
27
     *
28
     * @return void
29
     */
30
    public function __construct()
31
    {
32
        parent::__construct();
33
    }
34
35
    /**
36
     * Execute the console command.
37
     *
38
     * @return int
39
     */
40
    public function handle()
41
    {
42
        $name = $this->argument('name');
43
44
        CRUDGeneratorService::makeCRUD($name, $this);
45
46
        if ($this->option('acl')) {
47
            Artisan::call('make:permission '.$name.' --all');
48
            $this->info('ACL created ... ✅');
49
        }
50
51
        if ($this->option('api')) {
52
            Artisan::call('make:api '.$name);
53
            $this->info('API resource files created ... ✅');
54
        }
55
56
        if ($this->option('rest')) {
57
            Artisan::call('make:api '.$name.' --rest');
58
            $this->info('RestAPI files created ... ✅');
59
        }
60
61
        $this->info('CRUD made for model '.$name.' ... ✅');
62
    }
63
}
64