讨论数量:
我是这样弄的,创建下面的自定义行操作,然后加载这个操作就可以了,需要把详情方法改成 public (如有更好的办法也请告知)
<?php
namespace App\Admin\Actions\Grid;
use App\Admin\Renderable\DetailRenderable;
use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Widgets\Modal;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Route;
class Detail extends RowAction
{
/**
* @return string
*/
protected $title = '详情';
public function render()
{
// 实例化表单类并传递自定义参数
$show = DetailRenderable::make(['id' => $this->getKey(), 'controller' => Arr::first(explode('@', Route::current()->getActionName()))]);
return Modal::make()
->lg()
->body($show)
->button('<a href="javascript:void(0)"><i class="feather icon-eye"> ' . $this->title . '</i></a>');
}
}
<?php
namespace App\Admin\Renderable;
use Dcat\Admin\Support\LazyRenderable;
class DetailRenderable extends LazyRenderable
{
public function render()
{
return (new $this->payload['controller'])->detail($this->payload['id']);
}
}
推荐文章: