diff --git a/app/Console/Commands/untranslateShelves.php b/app/Console/Commands/untranslateShelves.php
index 9a02bfc7..749fae38 100644
--- a/app/Console/Commands/untranslateShelves.php
+++ b/app/Console/Commands/untranslateShelves.php
@@ -7,35 +7,14 @@ use App\Models\Shop\Category;
class untranslateShelves extends Command
{
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
protected $signature = 'untranslateShelves';
-
- /**
- * The console command description.
- *
- * @var string
- */
protected $description = 'Migrations of shelves';
- /**
- * Create a new command instance.
- *
- * @return void
- */
public function __construct()
{
parent::__construct();
}
- /**
- * Execute the console command.
- *
- * @return mixed
- */
public function handle()
{
$categories = Category::all();
diff --git a/app/Console/Commands/untranslateTags.php b/app/Console/Commands/untranslateTags.php
new file mode 100644
index 00000000..4a2ba686
--- /dev/null
+++ b/app/Console/Commands/untranslateTags.php
@@ -0,0 +1,27 @@
+get();
+ foreach ($tags as $tag) {
+ $trans = json_decode($tag->name, true);
+ $name = $trans['fr'];
+ $tag->update(['name' => $name]);
+ }
+ }
+}
diff --git a/app/Datatables/Botanic/SpeciesDataTable.php b/app/Datatables/Botanic/SpeciesDataTable.php
index 292f092e..ee891c59 100644
--- a/app/Datatables/Botanic/SpeciesDataTable.php
+++ b/app/Datatables/Botanic/SpeciesDataTable.php
@@ -21,7 +21,7 @@ class SpeciesDataTable extends DataTable
{
$datatables
->editColumn('thumb', function (Specie $specie) {
- return Species::getThumb($specie->image);
+ return Species::getThumb($specie->image, false);
})
->editColumn('genre_name', function (Specie $specie) {
return $specie->genre ? $specie->genre->name : '';
diff --git a/app/Datatables/Botanic/VarietiesDataTable.php b/app/Datatables/Botanic/VarietiesDataTable.php
index d25277af..9df6c858 100644
--- a/app/Datatables/Botanic/VarietiesDataTable.php
+++ b/app/Datatables/Botanic/VarietiesDataTable.php
@@ -22,7 +22,7 @@ class VarietiesDataTable extends DataTable
{
$datatables
->editColumn('thumb', function (Variety $variety) {
- return Varieties::getThumb($variety->image);
+ return Varieties::getThumb($variety->image, false);
})
->editColumn('tags2', function (Variety $variety) {
$html = '';
diff --git a/app/Datatables/Shop/ArticlesDataTable.php b/app/Datatables/Shop/ArticlesDataTable.php
index c270a138..0aa43eb7 100644
--- a/app/Datatables/Shop/ArticlesDataTable.php
+++ b/app/Datatables/Shop/ArticlesDataTable.php
@@ -7,6 +7,7 @@ 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;
class ArticlesDataTable extends DataTable
{
@@ -75,7 +76,7 @@ class ArticlesDataTable extends DataTable
->editColumn('tags2', function (Article $article) {
$html = '';
foreach ($article->tags as $tag) {
- $html .= '' . $tag->slug . ' ';
+ $html .= '' . Tags::getFullnameByTag($tag) . ' ';
}
return $html;
})
@@ -86,16 +87,16 @@ class ArticlesDataTable extends DataTable
protected function getColumns()
{
return [
- Column::make('visible')->title('Visible')->searchable(false),
- Column::make('homepage')->title('Accueil')->searchable(false),
+ Column::make('visible')->title('Visible')->searchable(false)->width(50),
+ Column::make('homepage')->title('Accueil')->searchable(false)->width(50),
Column::make('article_nature.name')->title('Nature'),
Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'),
Column::make('name')->title('Nom'),
Column::make('tags2')->title('Tags')->searchable(false)->orderable(false),
- Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false),
- Column::make('categories_count')->title('#Ray')->class('text-right')->searchable(false),
- Column::make('offers_count')->title('#Ofr')->class('text-right')->searchable(false),
- Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false),
+ Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false)->width(40),
+ Column::make('categories_count')->title('#Ray')->class('text-right')->searchable(false)->width(40),
+ Column::make('offers_count')->title('#Ofr')->class('text-right')->searchable(false)->width(40),
+ Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false)->width(40),
$this->makeColumnButtons(),
];
}
diff --git a/app/Datatables/Shop/TagsDataTable.php b/app/Datatables/Shop/TagsDataTable.php
index 72d2a2ef..a0b480ca 100644
--- a/app/Datatables/Shop/TagsDataTable.php
+++ b/app/Datatables/Shop/TagsDataTable.php
@@ -13,7 +13,7 @@ class TagsDataTable extends DataTable
public function query(Tag $model)
{
- $model = $model::with('group')->withCount(['articles', 'shelves', 'species', 'varieties']);
+ $model = $model::with('tag_group')->withCount(['articles', 'shelves', 'species', 'varieties']);
return $this->buildQuery($model);
}
@@ -30,7 +30,7 @@ class TagsDataTable extends DataTable
protected function getColumns()
{
return [
- Column::make('group.name')->title('Groupe')->width(200),
+ Column::make('tag_group.name')->title('Groupe')->width(200),
Column::make('name')->title('Nom'),
Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false)->width(60),
Column::make('species_count')->title('#Esp')->class('text-right')->searchable(false)->width(60),
diff --git a/app/Menu/Shop.php b/app/Menu/Shop.php
index 5c922604..1e824481 100644
--- a/app/Menu/Shop.php
+++ b/app/Menu/Shop.php
@@ -10,7 +10,6 @@ class Shop
{
$menu->add('En vente', ['icon' => 'shopping-cart' ])
->id('shop')
- ->activeIfRoute('shop')
->order(2);
$menu->addTo('shop', 'Articles', [
diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php
index b8341ad4..2fc17cd8 100644
--- a/app/Models/Shop/Tag.php
+++ b/app/Models/Shop/Tag.php
@@ -19,7 +19,7 @@ class Tag extends parentTag
'group',
'tag_group_id',
];
- public $translatable = ['name'];
+ public $translatable = [];
/*
public function taggable()
@@ -44,9 +44,9 @@ class Tag extends parentTag
return $this->morphedByMany(Category::class, 'taggable');
}
- public function group()
+ public function tag_group()
{
- return $this->hasOne(TagGroup::class, 'id', 'tag_group_id');
+ return $this->belongsTo(TagGroup::class);
}
public function shelves()
@@ -64,6 +64,11 @@ class Tag extends parentTag
return $this->morphedByMany(Variety::class, 'taggable');
}
+ public function merchandises()
+ {
+ return $this->morphedByMany(Merchandise::class, 'taggable');
+ }
+
public function scopeByGroup($query, $id)
{
return $query->where($this->table . '.tag_group_id', $id);
diff --git a/app/Models/Shop/TagGroup.php b/app/Models/Shop/TagGroup.php
index 596c3c0a..c6b9423f 100644
--- a/app/Models/Shop/TagGroup.php
+++ b/app/Models/Shop/TagGroup.php
@@ -8,7 +8,6 @@ class TagGroup extends Model
{
protected $guarded = ['id'];
protected $table = 'tag_groups';
- public $timestamps = false;
public function tags()
{
diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php
index 2972da64..2bd5384d 100644
--- a/app/Repositories/Shop/Articles.php
+++ b/app/Repositories/Shop/Articles.php
@@ -98,12 +98,15 @@ class Articles
case 'App\Models\Botanic\Variety':
$variety = $article->product;
$specie = $variety->specie;
- $description = empty($specie->description) ? '' : $specie->description . '
';
- $description .= empty($variety->description) ? '' : $variety->description . '
';
+ $description = $specie->description . $variety->description;
break;
case 'App\Models\Botanic\Specie':
$specie = $article->product;
- $description = empty($specie->description) ? '' : $specie->description . '
';
+ $description = $specie->description;
+ break;
+ case 'App\Models\Shop\Merchandise':
+ $merchandise = $article->product;
+ $description = $merchandise->description;
break;
default:
$description = '';
@@ -210,7 +213,6 @@ class Articles
return $data;
}
-
public static function getFull($id)
{
$data['article'] = self::getArticleEdit($id);
@@ -385,6 +387,46 @@ class Articles
return Article::find($id);
}
+ public static function getFullImagesByArticleId($id)
+ {
+ $article = self::get($id);
+ return $article ? self::getFullImagesByArticle($article) : false;
+ }
+
+ public static function countFullImagesByArticleId($id)
+ {
+ $article = self::get($id);
+ return $article ? self::countFullImagesByArticle($article) : 0;
+ }
+
+ public static function countFullImagesByArticle($article)
+ {
+ return count(self::getFullImagesByArticle($article));
+ }
+
+ public static function getFullImagesByArticle($article)
+ {
+ switch ($article->product_type) {
+ case 'App\Models\Botanic\Variety':
+ $variety = $article->product;
+ $specie = $variety->specie;
+ $images = count($variety->images) ? $variety->images : [];
+ $images = count($specie->images) ? $images->push($specie->images) : $images;
+ case 'App\Models\Botanic\Specie':
+ $specie = $article->product;
+ $images = count($specie->images) ? $specie->images : [];
+ break;
+ case 'App\Models\Shop\Merchandise':
+ $merchandise = $article->product;
+ $images = count($merchandise->images) ? $merchandise->images : [];
+ break;
+ default:
+ $images = [];
+ }
+ $images = count($article->images) ? $images->push($article->images) : $images;
+ return $images;
+ }
+
public static function getFullImageById($id)
{
$article = self::get($id);
diff --git a/app/Repositories/Shop/TagGroups.php b/app/Repositories/Shop/TagGroups.php
index 8f421535..9584a95c 100644
--- a/app/Repositories/Shop/TagGroups.php
+++ b/app/Repositories/Shop/TagGroups.php
@@ -2,6 +2,7 @@
namespace App\Repositories\Shop;
+use Illuminate\Support\Str;
use App\Models\Shop\TagGroup;
use App\Models\Shop\Tag;
@@ -69,6 +70,7 @@ class TagGroups
public static function create($data)
{
+ $data['slug'] = Str::slug($data['name']);
return TagGroup::create($data);
}
@@ -76,6 +78,7 @@ class TagGroups
{
$id = $id ? $id : $data['id'];
$model = self::get($id);
+ $data['slug'] = Str::slug($data['name']);
$model->update($data);
return $model;
}
diff --git a/app/Repositories/Shop/Tags.php b/app/Repositories/Shop/Tags.php
index 9f6b49ec..dd773e94 100644
--- a/app/Repositories/Shop/Tags.php
+++ b/app/Repositories/Shop/Tags.php
@@ -2,9 +2,7 @@
namespace App\Repositories\Shop;
-use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
-
use App\Models\Shop\Tag;
class Tags
@@ -27,9 +25,9 @@ class Tags
public static function getOptionsFullName()
{
- $tags = Tag::with('group')->get()->toArray();
+ $tags = Tag::with('tag_group')->get()->toArray();
foreach ($tags as $tag) {
- $data[$tag['id']] = $tag['group']['name'] . '-' . $tag['name'];
+ $data[$tag['id']] = $tag['tag_group']['name'] . '-' . $tag['name'];
}
return $data;
}
@@ -41,8 +39,13 @@ class Tags
public static function getFullname($id)
{
- $tag = Tag::with('group')->find($id);
- return $tag->group->name . '-' . $tag->name;
+ $tag = Tag::with('tag_group')->find($id);
+ return $tag ? self::getFullnameByTag($tag) : false;
+ }
+
+ public static function getFullnameByTag($tag)
+ {
+ return $tag->tag_group->name . '-' . $tag->name;
}
public static function get($id)