Created
July 29, 2020 09:15
-
-
Save introqt/078c8701b38d7434e1ed980887b1b425 to your computer and use it in GitHub Desktop.
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 characters
| <?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(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment