[WIP] Fix cosmetics, prices
This commit is contained in:
@@ -36,7 +36,7 @@ class ParentDataTable extends DataTable
|
||||
{
|
||||
$buttons = '';
|
||||
// $buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-secondary btn-show mr-2"><i class="fa fa-fw fa-eye"></i></button>';
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-primary btn-edit mr-2"><i class="fa fa-fw fa-edit"></i></button>';
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-primary btn-edit mr-2"><i class="fa fa-fw fa-pencil-alt"></i></button>';
|
||||
$buttons .= '<button type="button" data-id="{{$id}}" class="btn btn-xs btn-danger btn-del"><i class="fa fa-fw fa-trash"></i></button>';
|
||||
return $buttons;
|
||||
}
|
||||
@@ -82,9 +82,10 @@ class ParentDataTable extends DataTable
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId($id)
|
||||
->parameters($this->getParameters())
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
->dom('Bfrtip')
|
||||
->dom($this->getDom())
|
||||
->orderBy(0,'asc')
|
||||
->buttons(
|
||||
Button::make('export'),
|
||||
@@ -92,6 +93,27 @@ class ParentDataTable extends DataTable
|
||||
);
|
||||
}
|
||||
|
||||
public function getParameters()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getDom()
|
||||
{
|
||||
$dom = $this->getDatatablesHeaderDefault();
|
||||
$dom .= "rt";
|
||||
$dom .= $this->getDatatablesFooterDefault();
|
||||
return $dom;
|
||||
}
|
||||
|
||||
public function getDatatablesHeaderDefault() {
|
||||
return "<'row dt-toolbar-header'<'col-lg-4'l><'col-lg-4'B><'col-lg-4 text-right add'f>>";
|
||||
}
|
||||
|
||||
public function getDatatablesFooterDefault() {
|
||||
return "<'row dt-toolbar-footer'<'col-md-6'i><'col-md-6'p>>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get filename for export.
|
||||
*
|
||||
|
||||
@@ -12,15 +12,15 @@ class ArticleAttributeFamiliesDataTable extends DataTable
|
||||
|
||||
public function query(ArticleAttributeFamily $model)
|
||||
{
|
||||
$model = $model::withCount(['values']);
|
||||
$model = $model::withCount(['Attributes']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('values_count')->title('Nb valeurs')->searchable(false),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('attributes_count')->title('Nb attributs')->searchable(false)->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,15 +12,15 @@ class ArticleAttributeValuesDataTable extends DataTable
|
||||
|
||||
public function query(ArticleAttributeValue $model)
|
||||
{
|
||||
$model = $model::with(['attribute_family']);
|
||||
$model = $model::with(['ArticleAttributeFamily']);
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('attribute_family.name')->title('Famille d\'attributs') ,
|
||||
Column::make('value'),
|
||||
Column::make('value')->title('Attributs'),
|
||||
Column::make('article_attribute_family.name')->title('Famille d\'attributs')->sortable(false),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -12,13 +12,15 @@ class ArticleFamiliesDataTable extends DataTable
|
||||
|
||||
public function query(ArticleFamily $model)
|
||||
{
|
||||
$model = $model::withCount('Articles');
|
||||
return self::buildQuery($model);
|
||||
}
|
||||
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('name')->title('Nom'),
|
||||
Column::make('articles_count')->title('Nb articles')->addClass('text-right'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class CategoriesDataTable extends DataTable
|
||||
protected function getColumns()
|
||||
{
|
||||
return [
|
||||
Column::make('name'),
|
||||
Column::make('name')->title('Nom'),
|
||||
self::makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -20,6 +20,13 @@ class ArticleAttributeValueController extends Controller
|
||||
return ArticleAttributeValues::getTables($request->all());
|
||||
}
|
||||
|
||||
public function getOptionsByFamily(Request $request)
|
||||
{
|
||||
$id = $request->input('family_id');
|
||||
return response()->json(ArticleAttributeValues::getSelectByFamily($id));
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
return view('Shop.Admin.ArticleAttributeValues.create');
|
||||
|
||||
@@ -31,7 +31,8 @@ class ArticleController extends Controller
|
||||
$data['families'] = ArticleFamilies::getOptions();
|
||||
$data['attribute_families'] = ArticleAttributeFamilies::getOptions();
|
||||
$data['tags_list'] = TagGroups::getTreeTags();
|
||||
$data['models'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
// $data['models'] = ['App\Models\Botanic\Specie' => 'Espèces', 'App\Models\Botanic\Variety' => 'Variétés'];
|
||||
$data['models'] = ['App\Models\Botanic\Variety' => 'Variétés'];
|
||||
return view('Shop.Admin.Articles.create', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ class ArticleAttributeFamily extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_attribute_families';
|
||||
|
||||
public function Values()
|
||||
public function Attributes()
|
||||
{
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttributeValue','attribute_family_id');
|
||||
return $this->hasMany('App\Models\Shop\ArticleAttributeValue');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,14 +9,14 @@ class ArticleAttributeValue extends Model
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_article_attribute_values';
|
||||
|
||||
public function AttributeFamily()
|
||||
public function ArticleAttributeFamily()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Shop\ArticleAttributeFamily');
|
||||
}
|
||||
|
||||
public function scopeByFamily($query, $attribute_family_id)
|
||||
{
|
||||
return $query->where('attribute_family_id', $attribute_family_id);
|
||||
return $query->where('article_attribute_family_id', $attribute_family_id);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,12 +27,19 @@ class ArticleAttributeValues
|
||||
|
||||
public static function getOptions()
|
||||
{
|
||||
return ArticleAttributeValue::get()->pluck('name','id')->toArray();
|
||||
return ArticleAttributeValue::get()->pluck('value','id')->toArray();
|
||||
}
|
||||
|
||||
public static function getOptionsByFamily($attribute_family_id)
|
||||
public static function getSelectByFamily($attribute_family_id)
|
||||
{
|
||||
return ArticleAttributeValue::byFamily($attribute_family_id)->get()->pluck('name','id')->toArray();
|
||||
// return ArticleAttributeValue::byFamily($attribute_family_id)->get()->pluck('value','id')->toArray();
|
||||
$values = ArticleAttributeValue::byFamily($attribute_family_id)->get();
|
||||
$data = [];
|
||||
foreach ($values as $value)
|
||||
{
|
||||
$data[] = ['id' => $value->id, 'text' => $value->value];
|
||||
}
|
||||
return collect($data)->sortBy('text')->values()->all();
|
||||
}
|
||||
|
||||
public static function store($data)
|
||||
|
||||
@@ -51,6 +51,17 @@ class Articles
|
||||
return Article::destroy($id);
|
||||
}
|
||||
|
||||
public static function getImages($id)
|
||||
{
|
||||
$variety = self::get($id);
|
||||
$variety->getMedia();
|
||||
foreach ($variety->media as $key => $media) {
|
||||
$variety->media[$key]['url'] = $media->getUrl();
|
||||
}
|
||||
return $variety->media;
|
||||
}
|
||||
|
||||
|
||||
public static function deleteImage($id, $index)
|
||||
{
|
||||
$article = self::get($id);
|
||||
|
||||
Reference in New Issue
Block a user