body($this->simpleGrid()); } return $content ->title(trans('admin.permissions')) ->description(trans('admin.list')) ->body(function (Row $row) { if (request('_layout')) { $row->column(12, $this->grid()); } else { $row->column(12, $this->treeView()); } }); } /** * Show interface. * * @param mixed $id * @param Content $content * * @return Content */ public function show($id, Content $content) { return $content ->title(trans('admin.permissions')) ->description(trans('admin.detail')) ->body($this->detail($id)); } /** * Edit interface. * * @param $id * @param Content $content * * @return Content */ public function edit($id, Content $content) { return $content ->title(trans('admin.permissions')) ->description(trans('admin.edit')) ->body($this->form()->edit($id)); } /** * Create interface. * * @param Content $content * * @return Content */ public function create(Content $content) { return $content ->title(trans('admin.permissions')) ->description(trans('admin.create')) ->body($this->form()); } protected function simpleGrid() { $grid = new SimpleGrid(new Permission()); $grid->id->bold()->sortable(); $grid->slug; $grid->name; $grid->filter(function (Grid\Filter $filter) { $filter->like('slug'); $filter->like('name'); }); return $grid; } /** * @return \Dcat\Admin\Tree */ protected function treeView() { $model = config('admin.database.permissions_model'); $tree = new Tree(new $model()); $tree->disableCreateButton(); $tree->tools(function (Tree\Tools $tools) { $label = trans('admin.table'); $url = url(request()->getPathInfo()).'?_layout=1'; $tools->add("$label"); }); $tree->branch(function ($branch) { $payload = "
$path";
})->implode(' ');
$method = collect($method ?: ['ANY'])->unique()->map(function ($name) {
return strtoupper($name);
})->map(function ($name) {
return "{$name}";
})->implode(' ').' ';
$payload .= " $method$path";
return $payload;
});
return $tree;
}
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
$grid = new Grid(new Permission());
$grid->id('ID')->bold()->sortable();
$grid->name->tree();
$grid->slug->label('primary');
$grid->http_path->display(function ($path) {
if (! $path) {
return;
}
$method = $this->http_method ?: ['ANY'];
$method = collect($method)->map(function ($name) {
return strtoupper($name);
})->map(function ($name) {
return "{$name}";
})->implode(' ').' ';
return collect($path)->filter()->map(function ($path) use ($method) {
if (Str::contains($path, ':')) {
[$method, $path] = explode(':', $path);
$method = collect(explode(',', $method))->map(function ($name) {
return strtoupper($name);
})->map(function ($name) {
return "{$name}";
})->implode(' ').' ';
}
if (! empty(config('admin.route.prefix'))) {
$path = admin_base_path($path);
}
return "$path$path