Browse Source

模型树显示

develop
李可松 4 years ago
parent
commit
598d692d19
  1. 28
      app/AdminAgent/Controllers/ChannelController.php

28
app/AdminAgent/Controllers/ChannelController.php

@ -3,15 +3,41 @@
namespace App\AdminAgent\Controllers;
use App\AdminAgent\Repositories\Channel;
use App\Models\Channel as ChannelModel;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Layout\Row;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Tree;
use Illuminate\Support\Facades\Storage;
class ChannelController extends AdminController
{
/**
public function index(Content $content)
{
return $content->header('产品频道')
->body(function (Row $row) {
$tree = new Tree(new ChannelModel());
$tree->query(function ($model) {
//agent_id为0是系统分类,其它是代理商分类
return $model->where('agent_id', Admin::user()->id)->orderBy('sort')->orderBy('id');
});
/*$prefix = Storage::disk('public')->url('');
$tree->branch(function ($branch) use ($prefix) {
$src = $prefix . $branch['icon'] ;
$logo = '<img data-action="preview-img" src="'.$src.'" style="max-width:30px;max-height:30px;cursor:pointer;margin-left:20px;" class="img">';
return "{$branch['id']} - {$branch['name']} $logo";
});*/
$row->column(12, $tree);
});
}
/**
* Make a grid builder.
*
* @return Grid

Loading…
Cancel
Save