Projeto

Geral

Perfil

Estatísticas
| Branch: | Revisão:

expressolivretools / app / Console / Commands / Sogo / Preferences.php @ ab2f5151

Histórico | Ver | Anotar | Baixar (1,3 KB)

1
<?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
    protected $signature = 'sogo:get-user-preferences {--u|user=}';
17

    
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'lista preferências sogo do usuário';
24

    
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
        if( !is_null($user) ){
47

    
48
            $preferences =  $this->getPreferences($user);
49

    
50
            print_r( json_decode($preferences->c_defaults) );
51
        }
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
}