expressolivretools / app / Console / Commands / Sogo / Preferences.php @ ab2f5151
Histórico | Ver | Anotar | Baixar (1,3 KB)
1 | 3e379cec | Alexandre Correia | <?php
|
---|---|---|---|
2 | |||
3 | namespace App\Console\Commands\Sogo; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | use Illuminate\Support\Facades\DB; |
||
7 | use Storage; |
||
8 | |||
9 | class Preferences extends Command |
||
10 | { |
||
11 | /**
|
||
12 | * The name and signature of the console command.
|
||
13 | *
|
||
14 | * @var string
|
||
15 | */
|
||
16 | ab2f5151 | Alexandre Correia | protected $signature = 'sogo:get-user-preferences {--u|user=}'; |
17 | 3e379cec | Alexandre Correia | |
18 | /**
|
||
19 | * The console command description.
|
||
20 | *
|
||
21 | * @var string
|
||
22 | */
|
||
23 | ab2f5151 | Alexandre Correia | protected $description = 'lista preferências sogo do usuário'; |
24 | 3e379cec | Alexandre Correia | |
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 mixed
|
||
39 | */
|
||
40 | public function handle() |
||
41 | { |
||
42 | $arguments = $this->arguments(); |
||
43 | |||
44 | $user = $this->option('user') ?? null; |
||
45 | |||
46 | ab2f5151 | Alexandre Correia | if( !is_null($user) ){ |
47 | 3e379cec | Alexandre Correia | |
48 | ab2f5151 | Alexandre Correia | $preferences = $this->getPreferences($user); |
49 | 3e379cec | Alexandre Correia | |
50 | ab2f5151 | Alexandre Correia | print_r( json_decode($preferences->c_defaults) ); |
51 | 3e379cec | Alexandre Correia | } |
52 | |||
53 | $this->newLine();
|
||
54 | } |
||
55 | |||
56 | private function getPreferences( $user ) |
||
57 | { |
||
58 | $preferences = DB::connection('pgsql-sogo') |
||
59 | ->table('sogo_user_profile')
|
||
60 | ->where('c_uid', $user ) |
||
61 | ->first(); |
||
62 | |||
63 | return $preferences; |
||
64 | } |
||
65 | } |