REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.52 KB
Close
/home/byroehnu/easetack.com/app/Repositories/Frontend/ProductRepository.php
Text
Base64
<?php namespace App\Repositories\Frontend; use App\Models\Product; use Illuminate\Support\Facades\Cache; class ProductRepository { /** * Object model will be used to modify blogs table */ protected Product $model; /** * Constructor for blog repository */ public function __construct(Product $product) { $this->model = $product; } /** * Get search result with paginate * * @param array $sort */ public function paginateSearchResult($search, array $filter = [], $sort = 'latest') { $query = $this->model->with(['content', 'contents'])->newQuery(); // Apply search filters if necessary if (! empty($search)) { $query->whereHas('contents', function ($q) use ($search) { $q->where('title', 'like', "%{$search}%") ->orWhere('title', 'like', "%{$search}%"); })->orWhereHas('category.contents', function ($q) use ($search) { $q->where('title', 'like', "%{$search}%"); })->orWhereHas('tags', function ($q) use ($search) { $q->where('name', 'like', "%{$search}%"); }); } if (! empty($filter['category'])) { $query->whereHas('category.content', function ($q) use ($filter) { $q->where('title', $filter['category']); }); } if (! empty($filter['tag'])) { $query->withAnyTags([$filter['tag']]); } if (isset($filter['min_price']) && isset($filter['max_price'])) { $query->whereBetween('price', [ $filter['min_price'], $filter['max_price'], ]); } if (! empty($filter['sort'])) { switch ($filter['sort']) { case 'latest': $query->latest(); break; case 'low': $query->orderBy('price', 'asc'); break; case 'high': $query->orderBy('price', 'desc'); break; default: $query->latest(); break; } } else { $query->latest(); } return $query->where('status', '1')->paginate(perPage: 9); } public function getMaxProductPrice() { return Cache::remember('max_product_price', 3600, function () { return Product::selectRaw('MAX(price) as max_price')->value('max_price'); }); } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 9
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
BlogRepository.php
2.62 KB
lrw-rw-rw-
2025-04-19 04:22:15
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
CheckoutRepository.php
8.26 KB
lrw-rw-rw-
2025-05-15 11:24:11
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PageRepository.php
1.45 KB
lrw-rw-rw-
2025-04-19 04:22:15
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
PricingPlanRepository.php
6.38 KB
lrw-rw-rw-
2025-05-08 12:05:13
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProductRepository.php
2.52 KB
lrw-rw-rw-
2025-04-26 11:30:31
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ProfileRepository.php
1.77 KB
lrw-rw-rw-
2025-04-15 10:33:57
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
ReviewRepository.php
829 B
lrw-rw-rw-
2025-04-19 04:22:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
SearchRepository.php
5.46 KB
lrw-rw-rw-
2025-04-24 11:21:09
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
TicketRepository.php
3.50 KB
lrw-rw-rw-
2025-04-13 07:02:31
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).