Projeto

Geral

Perfil

Estatísticas
| Branch: | Revisão:

expressolivretools / app / Console / Commands / Sogo / Preferences.php @ 3e379cec

Histórico | Ver | Anotar | Baixar (1,69 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:preferences-get {--u|user=} {cmd?}';
17

    
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Lista as preferencias sogo do usuario';
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( isset($arguments['cmd']) && $arguments['cmd'] == 'help' )
47
        {
48
            $this->help();
49
            
50
        } else {
51

    
52
            if( !is_null($user) ){
53

    
54
                $preferences =  $this->getPreferences($user);
55

    
56
                print_r( json_decode($preferences->c_defaults) );
57
            }
58
        }
59

    
60
        $this->newLine();
61
    }
62

    
63
    private function getPreferences( $user )
64
    {
65
        $preferences = DB::connection('pgsql-sogo')
66
                            ->table('sogo_user_profile')
67
                            ->where('c_uid', $user )
68
                            ->first();
69

    
70
        return $preferences;
71
    }
72

    
73
    private function help()
74
    {
75
        $this->newLine();
76
        $this->info('EXEMPLO DE UTILIZACAO : ');
77
        $this->info('Ex: php artisan sogo:preferences-get --user=<usuario> { print | file }');
78
        $this->newLine();
79
    }
80
}