Fixes
This commit is contained in:
@@ -15,9 +15,16 @@ class ArticlesDataTable extends DataTable
|
||||
// $model = $model::with('Family')->select('shop_articles.*','family.name as family_name')->join('shop_article_families as family', 'family.id', '=', 'shop_articles.article_family_id')->groupBy('shop_articles.id');
|
||||
$model = $model::with('article_nature')->select('shop_articles.*');
|
||||
// $model = $model::joinRelations('Family')->select('shop_articles.*','shop_article_families.name as family_name');
|
||||
$model = self::filterByArticleNature($model);
|
||||
return self::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;
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -21,7 +21,6 @@ class TagsDataTable extends DataTable
|
||||
{
|
||||
return [
|
||||
Column::make('group.name')->title('Groupe'),
|
||||
Column::make('sort_order')->title('Ordre'),
|
||||
Column::make('name')->title('Nom'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
|
||||
@@ -18,7 +18,7 @@ class ArticleController extends Controller
|
||||
|
||||
public function index(ArticlesDataTable $dataTable)
|
||||
{
|
||||
$data['families'] = ArticleNatures::getOptions();
|
||||
$data['article_natures'] = ArticleNatures::getOptions();
|
||||
return $dataTable->render('Admin.Shop.Articles.list', $data);
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ class ArticleController extends Controller
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Articles::getMeta();
|
||||
$data['article'] = Articles::getFull($id);
|
||||
$data = Articles::getFull($id);
|
||||
return view('Admin.Shop.Articles.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,16 +61,26 @@ class Article extends Model implements HasMedia
|
||||
|
||||
public function scopeByArticle($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.id', $id);
|
||||
return $query->where($this->table . '.id', $id);
|
||||
}
|
||||
|
||||
public function scopeByCategory($query, $category_id)
|
||||
{
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $id)
|
||||
public function scopeByArticleNature($query, $id)
|
||||
{
|
||||
return $query->where('shop_articles.article_family_id', $id);
|
||||
return $query->where($this->table . '.article_nature_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByProduct($query, $model)
|
||||
{
|
||||
return $query->where($this->table . '.product_type', $model);
|
||||
}
|
||||
|
||||
public function scopeByProductId($query, $model_id)
|
||||
{
|
||||
return $query->where($this->table . '.product_id', $model_id);
|
||||
}
|
||||
|
||||
public function registerMediaConversions(Media $media = null) : void
|
||||
|
||||
@@ -46,7 +46,7 @@ class Articles
|
||||
|
||||
public static function getFull($id)
|
||||
{
|
||||
$data = self::getArticleEdit($id);
|
||||
$data['article'] = self::getArticleEdit($id);
|
||||
self::getMeta($data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user