CreateButton.php
1.8 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
59
60
61
62
63
64
65
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
* 重写 laravel-admin 类
+-----------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Admin\Rewrite\Grid\Tools
* @package App\Admin\Rewrite\Grid\Tools
* @author Richer <yangzi1028@163.com>
* @date 2021年12月20日14:44:55
* @copyright 2021-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
namespace App\Admin\Rewrite\Grid\Tools;
use Encore\Admin\Grid\Tools\CreateButton as Base;
use Illuminate\Support\Arr;
/**
* Class CreateButton
*
* @category App\Admin\Rewrite\Grid\Tools
* @package App\Admin\Rewrite\Grid\Tools
* @author Richer <yangzi1028@163.com>
* @date 2021年12月20日14:44:55
* @copyright 2021-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
class CreateButton extends Base
{
/**
* Render CreateButton.
*
* @return string
*/
public function render()
{
if (!$this->grid->showCreateBtn()) {
return '';
}
$url = "{$this->grid->getCreateUrl()}";
$params = explode('?', request()->getUri());
// 如果有参数
if (count($params) > 1) {
$url .= '?'.Arr::last($params);
}
$action = __('new');
return <<<EOT
<div class="btn-group pull-right grid-create-btn" style="margin-right: 10px">
<a href="{$url}" class="btn btn-success grid-row-new" title="{$action}">
<i class="fa fa-plus"></i><span class="hidden-xs"> {$action}</span>
</a>
</div>
EOT;
}
}