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 @@ + +
+ ... +
+ {{ $offer['article']['name'] }} + + + + +

+

+
+ 3.50 €
+ Semence +
+ +
+ 1.65 €
+ Plant +
+
+

+
+
+
diff --git a/resources/views/Shop/Offers/offer.blade.php b/resources/views/Shop/Offers/offer.blade.php new file mode 100644 index 00000000..8476f5c8 --- /dev/null +++ b/resources/views/Shop/Offers/offer.blade.php @@ -0,0 +1,25 @@ + +
+ ... +
+ {{ $offer['article']['name'] }} + + + + +

+

+
+ 3.50 €
+ Semence +
+ +
+ 1.65 €
+ Plant +
+
+

+
+
+
diff --git a/resources/views/Shop/layout/layout2.twig b/resources/views/Shop/layout/layout2.twig deleted file mode 100644 index 3eaced46..00000000 --- a/resources/views/Shop/layout/layout2.twig +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - OpenSemis - - - - - - - - - - - - -
- - {{ include("Shop.layout.partials.header") }} - {{ include("Shop._partials.notifications") }} - -
- -
-
-
-
- - {{ include("Shop._partials.slider") }} - {{ include("Shop._partials.block-banner") }} - {{ include("Shop._partials.block-products") }} - - - {{ include("Shop._partials.block-breadcrumb") }} - {{ include("Shop._partials.wrapper") }} - - {{ include("Shop._partials.block-bottom")}} - - {{ include("Shop._partials.footer")}} - -
-
- -   - - - - - - \ No newline at end of file diff --git a/resources/views/Shop/layout/partials/article.blade.php b/resources/views/Shop/layout/partials/article.blade.php deleted file mode 100644 index d3ea313a..00000000 --- a/resources/views/Shop/layout/partials/article.blade.php +++ /dev/null @@ -1,23 +0,0 @@ -
- ... -
- {{ $offer['article']['name'] }} - - - - -

-

-
- 3.10 €
- Semence -
- -
- 1.65 €
- Plant -
-
-

-
-
diff --git a/resources/views/Shop/layout/partials/block-articles.blade.php b/resources/views/Shop/layout/partials/block-articles.blade.php index 7fc8611f..c8a53bfc 100644 --- a/resources/views/Shop/layout/partials/block-articles.blade.php +++ b/resources/views/Shop/layout/partials/block-articles.blade.php @@ -1,7 +1,7 @@
@foreach ($articles as $article)
- @include('Shop.layout.partials.article') + @include('Shop.Articles.article')
@endforeach
\ No newline at end of file diff --git a/resources/views/Shop/layout/partials/category_articles.blade.php b/resources/views/Shop/layout/partials/category_articles.blade.php index f7327820..3440339d 100644 --- a/resources/views/Shop/layout/partials/category_articles.blade.php +++ b/resources/views/Shop/layout/partials/category_articles.blade.php @@ -1,7 +1,7 @@
@foreach ($offers as $offer)
- @include('Shop.layout.partials.article') + @include('Shop.Offers.offer')
@endforeach
\ No newline at end of file diff --git a/routes/Shop/Offers.php b/routes/Shop/Offers.php new file mode 100644 index 00000000..4800bee2 --- /dev/null +++ b/routes/Shop/Offers.php @@ -0,0 +1,6 @@ +name('Offers.')->group(function () { + Route::get('show/{id}', 'OfferController@show')->name('show'); +}); + diff --git a/routes/Shop/route.php b/routes/Shop/route.php index 7f5b0146..77ce352b 100644 --- a/routes/Shop/route.php +++ b/routes/Shop/route.php @@ -1,9 +1,10 @@ namespace('Shop')->name('Shop.')->group(function () { - include( __DIR__ . '/Articles.php'); - include( __DIR__ . '/Categories.php'); - include( __DIR__ . '/Customers.php'); - include( __DIR__ . '/Invoices.php'); - include( __DIR__ . '/Orders.php'); + include( __DIR__ . '/Articles.php'); + include( __DIR__ . '/Categories.php'); + include( __DIR__ . '/Customers.php'); + include( __DIR__ . '/Invoices.php'); + include( __DIR__ . '/Offers.php'); + include( __DIR__ . '/Orders.php'); });