TrashedButton.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Admin\Rewrite\Grid\Tools;
use App\Admin\Rewrite\Grid;
use Encore\Admin\Grid\Tools\AbstractTool;
class TrashedButton extends AbstractTool
{
/**
* @var Grid
*/
protected $grid;
/**
* Create a new CreateButton instance.
*
* @param Grid $grid
*/
public function __construct(Grid $grid)
{
$this->grid = $grid;
}
/**
* Render CreateButton.
*
* @return string
*/
public function render()
{
if (!$this->grid->showTrashedBtn()) {
return '';
}
if (request('trashed') == 1) {
return <<<EOT
<div class="btn-group pull-right grid-common-btn" style="margin-right: 10px">
<a href="{$this->grid->getCommonUrl()}" class="btn btn-sm btn-primary" title="全部">
<i class="fa fa-th"></i><span class="hidden-xs"> 全部</span>
</a>
</div>
EOT;
} else {
$title = trans('admin.trashed');
return <<<EOT
<div class="btn-group pull-right grid-trashed-btn" style="margin-right: 10px">
<a href="{$this->grid->getTrashedUrl()}" class="btn btn-sm btn-secondary" title="{$title}">
<i class="fa fa-trash"></i><span class="hidden-xs"> {$title}</span>
</a>
</div>
EOT;
}
}
}