1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Laravel MultiLang package. |
4
|
|
|
* |
5
|
|
|
* (c) Avtandil Kikabidze aka LONGMAN <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Longman\LaravelMultiLang\Console; |
12
|
|
|
|
13
|
|
|
use Illuminate\Console\Command; |
14
|
|
|
|
15
|
|
|
class TextsCommand extends Command |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The console command name. |
19
|
|
|
* |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
protected $signature = 'multilang:texts |
23
|
|
|
{--lang= : The lang to show} |
24
|
|
|
{--scope= : The scope to show} |
25
|
|
|
'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The console command description. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $description = 'Show multilang texts and translations.'; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Execute the console command. |
36
|
|
|
* |
37
|
|
|
* @return void |
38
|
|
|
*/ |
39
|
|
|
public function handle() |
40
|
|
|
{ |
41
|
|
|
$lang = $this->option('lang'); |
42
|
|
|
$scope = $this->option('scope'); |
43
|
|
|
|
44
|
|
|
$texts = app('multilang')->getAllTexts($lang, $scope); |
45
|
|
|
|
46
|
|
|
if (empty($texts)) { |
47
|
|
|
$this->info('Application texts is empty'); |
48
|
|
|
|
49
|
|
|
return false; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$headers = ['#', 'Text Key', 'Language', 'Scope', 'Text Value']; |
53
|
|
|
|
54
|
|
|
$rows = []; |
55
|
|
|
$i = 1; |
56
|
|
|
foreach ($texts as $lang => $items) { |
57
|
|
|
foreach ($items as $key => $item) { |
58
|
|
|
$row = [$i, $key, $item->lang, $item->scope, $item->value]; |
59
|
|
|
$rows[] = $row; |
60
|
|
|
$i++; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
$this->table($headers, $rows); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|