Completed
Push — master ( f91fe8...410c26 )
by Quim González
03:25
created

ShowTaskCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 55
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 23 3
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Http\Requests\Traits\AsksForTasks;
6
use App\Task;
7
use Illuminate\Console\Command;
8
use Mockery\Exception;
9
10
class ShowTaskCommand extends Command
11
{
12
    use AsksForTasks;
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'task:show {id? : The Task id}';
19
20
    /**
21
     * The console command description.
22
     *
23
     * @var string
24
     */
25
    protected $description = 'Show a Task by id';
26
27
    /**
28
     * Create a new command instance.
29
     *
30
     * @return void
31
     */
32
    public function __construct()
33
    {
34
        parent::__construct();
35
    }
36
37
    /**
38
     * Execute the console command.
39
     *
40
     * @return mixed
41
     */
42
    public function handle()
43
    {
44
        //si no me passen id, el demano.
45
        $id = $this->argument('id') ? $this->argument('id') : $this->askForTasks();
46
        $task = Task::findOrFail($id);
47
48
        try{
49
50
            $headers = ['Key', 'Value'];
51
            $info = [
52
                ['id', $task->id],
53
                ['Name', $task->name],
54
                ['User_id', $task->user_id],
55
                ['Description', $task->description],
56
57
58
59
            ];
60
            $this->table($headers,$info);
61
62
        }catch(Exception $e){
63
64
            $this->error('error' . $e);
65
        }
66
67
    }
68
}
69