add shipping rules
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Category;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class CategoriesDataTable extends DataTable
|
||||
{
|
||||
@@ -13,46 +13,49 @@ class CategoriesDataTable extends DataTable
|
||||
public function query(Category $model)
|
||||
{
|
||||
$model = $model::notRoot()->with(['tags.articles'])->withCount(['articles', 'tags']);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('name', function (Category $category) {
|
||||
return $category->name;
|
||||
})
|
||||
->editColumn('visible', function (Category $category) {
|
||||
return view("components.form.toggle", [
|
||||
'name' => 'visible',
|
||||
'value' => $category->visible,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id=' . $category->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'visible',
|
||||
]);
|
||||
})
|
||||
->editColumn('homepage', function (Category $category) {
|
||||
return view("components.form.toggle", [
|
||||
'name' => 'homepage',
|
||||
'value' => $category->homepage,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id=' . $category->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'homepage',
|
||||
]);
|
||||
})
|
||||
->editColumn('articles_tagged_count', function (Category $category) {
|
||||
$count = 0;
|
||||
foreach ($category->tags as $tag) {
|
||||
$nb = collect($tag->articles)->count();
|
||||
$count += $nb;
|
||||
}
|
||||
return $count;
|
||||
})
|
||||
->rawColumns(['visible', 'action']);
|
||||
->editColumn('name', function (Category $category) {
|
||||
return $category->name;
|
||||
})
|
||||
->editColumn('visible', function (Category $category) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'visible',
|
||||
'value' => $category->visible,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$category->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'visible',
|
||||
]);
|
||||
})
|
||||
->editColumn('homepage', function (Category $category) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'homepage',
|
||||
'value' => $category->homepage,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$category->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'homepage',
|
||||
]);
|
||||
})
|
||||
->editColumn('articles_tagged_count', function (Category $category) {
|
||||
$count = 0;
|
||||
foreach ($category->tags as $tag) {
|
||||
$nb = collect($tag->articles)->count();
|
||||
$count += $nb;
|
||||
}
|
||||
|
||||
return $count;
|
||||
})
|
||||
->rawColumns(['visible', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user