1 | <?php |
||
2 | |||
3 | namespace App\Console\Commands; |
||
4 | |||
5 | use App\Http\Requests\Traits\AsksForUsers; |
||
6 | use App\User; |
||
7 | use Illuminate\Console\Command; |
||
8 | |||
9 | class ShowUserCommand extends Command |
||
10 | { |
||
11 | use AsksForUsers; |
||
12 | /** |
||
13 | * The name and signature of the console command. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $signature = 'user:show {id? : The User id}'; |
||
18 | |||
19 | /** |
||
20 | * The console command description. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | protected $description = 'Show a User by id.'; |
||
25 | |||
26 | /** |
||
27 | * Create a new command instance. |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | public function __construct() |
||
32 | { |
||
33 | parent::__construct(); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Execute the console command. |
||
38 | * |
||
39 | * @return mixed |
||
40 | */ |
||
41 | public function handle() |
||
42 | { |
||
43 | //si no me passen id, el demano. |
||
44 | $id = $this->argument('id') ? $this->argument('id') : $this->askForUsers(); |
||
45 | $user = User::findOrFail($id); |
||
46 | |||
47 | try { |
||
48 | $headers = ['Key', 'Value']; |
||
49 | $info = [ |
||
50 | ['id', $user->id], |
||
51 | ['Name', $user->name], |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
52 | ['email', $user->email], |
||
0 ignored issues
–
show
The property
email does not exist on App\User . Since you implemented __get , consider adding a @property annotation.
![]() |
|||
53 | ]; |
||
54 | $this->table($headers, $info); |
||
55 | } catch (Exception $e) { |
||
0 ignored issues
–
show
|
|||
56 | $this->error('error'.$e); |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 |