add shipping rules

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 14:45:42 +02:00
parent 72a7b270f9
commit 0879b0abf0
459 changed files with 6219 additions and 5416 deletions

View File

@@ -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);
}