|
1
|
|
|
<?php namespace Serverfireteam\Panel\Commands; |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Console\Command; |
|
4
|
|
|
use Serverfireteam\Panel\Link; |
|
5
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
6
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
7
|
|
|
|
|
8
|
|
|
class CrudCommand extends Command { |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* |
|
12
|
|
|
* @var string |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $name = 'panel:crud'; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* |
|
18
|
|
|
* @var string the statement before installation starts |
|
19
|
|
|
*/ |
|
20
|
|
|
protected $description = 'Create new crud for you'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Create a new command instance. |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
public function __construct() |
|
27
|
|
|
{ |
|
28
|
|
|
parent::__construct(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Execute the console command. |
|
33
|
|
|
* |
|
34
|
|
|
*/ |
|
35
|
|
|
public function handle() |
|
36
|
|
|
{ |
|
37
|
|
|
|
|
38
|
|
|
$this->info(' [ ServerFireTeam Panel Crud Generator ] '); |
|
39
|
|
|
|
|
40
|
|
|
$crudName = $this->argument('name'); |
|
41
|
|
|
|
|
42
|
|
|
$this->call('panel:createmodel', ['name' => $crudName]); |
|
43
|
|
|
|
|
44
|
|
|
$this->call('panel:createcontroller', ['name' => $crudName]); |
|
45
|
|
|
|
|
46
|
|
|
Link::create([ |
|
47
|
|
|
'url' => $crudName, |
|
48
|
|
|
'display' => $crudName . 's', |
|
49
|
|
|
'show_menu' => true, |
|
50
|
|
|
]); |
|
51
|
|
|
|
|
52
|
|
|
if ( !\Schema::hasTable($crudName) ){ |
|
53
|
|
|
$this->info(' The Table Corresponding to this Model does not exist in Database!! '); |
|
54
|
|
|
$this->info(' Please Create this table '); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Get the console command arguments. |
|
61
|
|
|
* |
|
62
|
|
|
* @return array |
|
63
|
|
|
*/ |
|
64
|
|
|
protected function getArguments() |
|
65
|
|
|
{ |
|
66
|
|
|
return [ |
|
67
|
|
|
['name', InputArgument::REQUIRED, 'required argument names'] |
|
68
|
|
|
]; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Get the console command options. |
|
73
|
|
|
* |
|
74
|
|
|
* @return array |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function getOptions() |
|
77
|
|
|
{ |
|
78
|
|
|
return []; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|