diff --git a/app/Http/Controllers/Shop/HomeController.php b/app/Http/Controllers/Shop/HomeController.php
index d5afb2b3..7f9b871c 100644
--- a/app/Http/Controllers/Shop/HomeController.php
+++ b/app/Http/Controllers/Shop/HomeController.php
@@ -20,6 +20,8 @@ class HomeController extends Controller
{
$data = self::init();
$data['offers'] = Offers::getLast()->toArray();
+ dump($data);
+ exit;
return view('Shop.home', $data);
}
}
diff --git a/app/Http/Controllers/Shop/OfferController.php b/app/Http/Controllers/Shop/OfferController.php
new file mode 100644
index 00000000..489f8442
--- /dev/null
+++ b/app/Http/Controllers/Shop/OfferController.php
@@ -0,0 +1,17 @@
+has('Offers');
+ return $query->has('offers');
+ }
+
+ public function scopeWithCurrentOffers($query)
+ {
+ return $query->whereHas('offers', function ($query) {
+ $query->where('status_id', 1);
+ });
}
}
diff --git a/app/Models/Shop/Category.php b/app/Models/Shop/Category.php
index b30f2840..8e1bef47 100644
--- a/app/Models/Shop/Category.php
+++ b/app/Models/Shop/Category.php
@@ -14,9 +14,11 @@ use Spatie\Translatable\HasTranslations;
use Rinvex\Tags\Traits\Taggable;
use Wildside\Userstamps\Userstamps;
+use Kalnoy\Nestedset\NodeTrait;
+
class Category extends Model
{
- use HasTranslations, InteractsWithMedia, SoftDeletes, Taggable, Userstamps;
+ use HasTranslations, InteractsWithMedia, NodeTrait, SoftDeletes, Taggable, Userstamps;
protected $guarded = ['id'];
protected $table = 'categories';
@@ -41,4 +43,9 @@ class Category extends Model
{
return $query->where('category_id', $category_id);
}
+
+ public function scopeVisible($query)
+ {
+ return $query->where('visible', 1);
+ }
}
diff --git a/app/Models/Shop/Offer.php b/app/Models/Shop/Offer.php
index bc32de1a..30b7a77a 100644
--- a/app/Models/Shop/Offer.php
+++ b/app/Models/Shop/Offer.php
@@ -38,6 +38,11 @@ class Offer extends Model
return $this->belongsTo(Variation::class);
}
+ public function scopeActive($query)
+ {
+ return $query->where('status_id', 1);
+ }
+
public function scopeByArticle($query, $id)
{
return $query->where('article_id', $id);
diff --git a/app/Repositories/Core/Categories.php b/app/Repositories/Core/Categories.php
index 2bfacbf7..cdbf3d96 100644
--- a/app/Repositories/Core/Categories.php
+++ b/app/Repositories/Core/Categories.php
@@ -6,11 +6,6 @@ use App\Repositories\Core\Arrays;
class Categories
{
- public static function getTree($withFolder = false)
- {
- $categories = self::getCategoryTree()->toArray();
- return self::getChildren($categories[0]['children'], $withFolder);
- }
public static function getFancyTree()
{
@@ -20,6 +15,12 @@ class Categories
return $categories;
}
+ public static function getTree($withFolder = false)
+ {
+ $categories = self::getCategoryTree()->toArray();
+ return self::getChildren($categories[0]['children'], $withFolder);
+ }
+
public static function getCategoryTree()
{
return self::getModel()->defaultOrder()->get()->toTree();
diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php
index 5ee88df5..948bd6dc 100644
--- a/app/Repositories/Shop/Articles.php
+++ b/app/Repositories/Shop/Articles.php
@@ -59,6 +59,11 @@ class Articles
return $data;
}
+ public static function getArticlesWithOffers()
+ {
+ return Article::withCurrentOffers()->with('offers')->get();
+ }
+
public static function getFull($id)
{
$data['article'] = self::getArticleEdit($id);
diff --git a/app/Repositories/Shop/Categories.php b/app/Repositories/Shop/Categories.php
index b06b1a57..1fd43dc3 100644
--- a/app/Repositories/Shop/Categories.php
+++ b/app/Repositories/Shop/Categories.php
@@ -38,6 +38,11 @@ class Categories
return $category->tags->pluck('name', 'id')->toArray();
}
+ public static function getTreeVisibles()
+ {
+ $tree = Category::get()->toTree();
+ }
+
public static function getTree()
{
return CategoryTrees::getTree();
diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php
index b11e9c60..a06e359e 100644
--- a/app/Repositories/Shop/Offers.php
+++ b/app/Repositories/Shop/Offers.php
@@ -19,7 +19,7 @@ class Offers
public static function getLast()
{
- return Offer::with(['article.image'])->orderByDesc('updated_at')->get();
+ return Offer::with(['article.image'])->active()->orderByDesc('updated_at')->get();
}
public static function getByCategoryWithTags($category_id)
diff --git a/resources/views/Shop/Articles/article.blade.php b/resources/views/Shop/Articles/article.blade.php
new file mode 100644
index 00000000..8476f5c8
--- /dev/null
+++ b/resources/views/Shop/Articles/article.blade.php
@@ -0,0 +1,25 @@
+
+
+
+
+
+ Semence
+
+ Plant
+
+
+ Semence
+
+ Plant
+
-