1 | <?php |
||
8 | class CreateTaskCommand extends Command |
||
9 | { |
||
10 | /** |
||
11 | * The name and signature of the console command. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | protected $signature = 'projects:create-task'; |
||
16 | |||
17 | /** |
||
18 | * The console command description. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $description = 'Laravel Artisan Command to create a new task.'; |
||
23 | |||
24 | /** |
||
25 | * Task model. |
||
26 | * |
||
27 | * @var object |
||
28 | */ |
||
29 | private $task; |
||
30 | |||
31 | /** |
||
32 | * Create a new command instance. |
||
33 | * |
||
34 | * @return void |
||
|
|||
35 | */ |
||
36 | public function __construct(Task $task) |
||
42 | |||
43 | /** |
||
44 | * Execute the console command. |
||
45 | * |
||
46 | * @return mixed |
||
47 | */ |
||
48 | public function handle() |
||
56 | |||
57 | /** |
||
58 | * Ask for task details. |
||
59 | * |
||
60 | * @return array |
||
61 | */ |
||
62 | private function getDetails() : array |
||
71 | |||
72 | /** |
||
73 | * Display created task. |
||
74 | * |
||
75 | * @param array $task |
||
76 | * @return void |
||
77 | */ |
||
78 | private function display(Task $task) : void |
||
92 | } |
||
93 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.