Created
July 29, 2020 09:15
-
-
Save introqt/078c8701b38d7434e1ed980887b1b425 to your computer and use it in GitHub Desktop.
Revisions
-
introqt created this gist
Jul 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ <?php declare(strict_types=1); namespace Modules\Home\Services; use App\Core\Enums\BaseEnum; use Illuminate\Database\Eloquent\Collection; use Modules\Home\Entities\ArticleOnMain; use Modules\Home\Entities\ProductCategoryOnMain; use Modules\Home\Entities\SeasonalOffer; use Modules\Home\Entities\Slider; use App\Models\Page; /** * Class HomePage * @package Modules\Home\Services */ class HomePage implements HomePageInterface { /** * @return Collection|SeasonalOffer[] */ public function getSeasonalOffers(): Collection { return SeasonalOffer::active()->with('product.products')->get(); } /** * @return Collection|ArticleOnMain[] */ public function getArticles(): Collection { return ArticleOnMain::with('article')->active()->sort()->get(); } /** * @return Collection|ProductCategoryOnMain[] */ public function getProductCategories(): Collection { return ProductCategoryOnMain::whereHas('category', function ($q) { $q->active(); })->active()->sort()->get(); } /** * @return Collection|Slider[] */ public function getSliders(): Collection { return Slider::active()->sort()->get(); } /** * @return Page */ public function getPage(): Page { return Page::query()->whereUrl('/')->firstOrFail(); } }