add shipping rules
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
|
||||
namespace App\Datatables\Shop;
|
||||
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
use App\Datatables\ParentDataTable as DataTable;
|
||||
use App\Models\Shop\Article;
|
||||
use App\Repositories\Shop\Articles;
|
||||
use App\Repositories\Shop\Tags;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
|
||||
class ArticlesDataTable extends DataTable
|
||||
{
|
||||
public $model_name = 'articles';
|
||||
|
||||
public $sortedColumn = 2;
|
||||
|
||||
public function query(Article $model)
|
||||
@@ -20,70 +20,77 @@ class ArticlesDataTable extends DataTable
|
||||
$model = self::filterByArticleNature($model);
|
||||
$model = self::filterByCategory($model);
|
||||
$model = self::filterByTag($model);
|
||||
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
public static function filterByArticleNature($model, $article_nature_id = false)
|
||||
{
|
||||
$article_nature_id = $article_nature_id ? $article_nature_id : self::isFilteredByField('article_nature_id');
|
||||
|
||||
return $article_nature_id ? $model->byArticleNature($article_nature_id) : $model;
|
||||
}
|
||||
|
||||
public static function filterByCategory($model, $category_id = false)
|
||||
{
|
||||
$category_id = $category_id ? $category_id : self::isFilteredByField('category_id');
|
||||
|
||||
return $category_id ? $model->byCategory($category_id) : $model;
|
||||
}
|
||||
|
||||
public static function filterByTag($model, $tag_id = false)
|
||||
{
|
||||
$tag_id = $tag_id ? $tag_id : self::isFilteredByField('tag_id');
|
||||
|
||||
return $tag_id ? $model->byTag($tag_id) : $model;
|
||||
}
|
||||
|
||||
public function modifier($datatables)
|
||||
{
|
||||
$datatables
|
||||
->editColumn('visible', function (Article $article) {
|
||||
return view("components.form.toggle", [
|
||||
'name' => 'visible',
|
||||
'value' => $article->visible,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id=' . $article->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'visible',
|
||||
]);
|
||||
})
|
||||
->editColumn('homepage', function (Article $article) {
|
||||
return view("components.form.toggle", [
|
||||
'name' => 'homepage',
|
||||
'value' => $article->homepage,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id=' . $article->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'homepage',
|
||||
]);
|
||||
})
|
||||
->editColumn('thumb', function (Article $article) {
|
||||
$image = Articles::getFullImageByArticle($article);
|
||||
return Articles::getThumb($image, false);
|
||||
})
|
||||
->editColumn('article_nature.name', function (Article $article) {
|
||||
return $article->article_nature ? $article->article_nature->name : '';
|
||||
})
|
||||
->editColumn('tags2', function (Article $article) {
|
||||
$html = '';
|
||||
foreach ($article->tags as $tag) {
|
||||
$html .= Tags::getTagHtml($tag);
|
||||
}
|
||||
return $html;
|
||||
})
|
||||
->editColumn('images_count2', function (Article $article) {
|
||||
return Articles::countFullImagesByArticle($article);
|
||||
})
|
||||
->rawColumns(['tags2', 'thumb', 'action']);
|
||||
->editColumn('visible', function (Article $article) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'visible',
|
||||
'value' => $article->visible,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$article->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'visible',
|
||||
]);
|
||||
})
|
||||
->editColumn('homepage', function (Article $article) {
|
||||
return view('components.form.toggle', [
|
||||
'name' => 'homepage',
|
||||
'value' => $article->homepage,
|
||||
'on' => __('oui'),
|
||||
'off' => __('non'),
|
||||
'meta' => 'data-id='.$article->id,
|
||||
'size' => 'sm',
|
||||
'class' => 'homepage',
|
||||
]);
|
||||
})
|
||||
->editColumn('thumb', function (Article $article) {
|
||||
$image = Articles::getFullImageByArticle($article);
|
||||
|
||||
return Articles::getThumb($image, false);
|
||||
})
|
||||
->editColumn('article_nature.name', function (Article $article) {
|
||||
return $article->article_nature ? $article->article_nature->name : '';
|
||||
})
|
||||
->editColumn('tags2', function (Article $article) {
|
||||
$html = '';
|
||||
foreach ($article->tags as $tag) {
|
||||
$html .= Tags::getTagHtml($tag);
|
||||
}
|
||||
|
||||
return $html;
|
||||
})
|
||||
->editColumn('images_count2', function (Article $article) {
|
||||
return Articles::countFullImagesByArticle($article);
|
||||
})
|
||||
->rawColumns(['tags2', 'thumb', 'action']);
|
||||
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user