Compare commits

...

4 Commits

Author SHA1 Message Date
Mekan1206
82ed332637 WIP 2026-05-03 19:08:02 +05:00
Mekan1206
bac2ad9a3e WIP 2026-05-03 18:42:16 +05:00
Mekan1206
1b467108de WIP 2026-05-03 18:36:49 +05:00
Mekan1206
774ac3c622 remove modal 2026-05-02 16:19:31 +05:00
3 changed files with 37 additions and 60 deletions

View File

@@ -6,6 +6,7 @@ use App\Http\Controllers\Api\V1\Filters\Requests\FilterIndexRequest;
use App\Http\Controllers\Controller;
use App\Models\Ecommerce\Channel\Channel;
use App\Models\Ecommerce\Product\Brand\Brand;
use Illuminate\Support\Facades\DB;
use App\Models\Ecommerce\Product\Category\Category;
use App\Models\Ecommerce\Product\Collection\Collection;
use Illuminate\Http\JsonResponse;
@@ -45,7 +46,7 @@ class FilterController extends Controller
}
if ($this->shouldFilterByCollection()) {
return $this->filterByCategoryResource(Collection::find($this->request->collection_id));
return $this->categoriesFor();
}
if ($this->shouldFilterByBrand()) {
@@ -62,29 +63,29 @@ class FilterController extends Controller
private function brands()
{
if ($this->shouldFilterByBrand()) {
return Brand::query()->where('id', $this->request->brand_id)->get(['id', 'name']);
return Brand::where('id', $this->request->brand_id)->get(['id', 'name']);
}
if ($this->shouldFilterByCategory()) {
$brands = Category::query()->find($this->request->category_id)->products()
$brands = Category::find($this->request->category_id)->products()
->where('products.is_visible', true)
->where('products.parent_id', null)
->where('products.stock', '>', 0)
->distinct('products.brand_id')
->pluck('products.brand_id');
return Brand::query()->whereIntegerInRaw('id', $brands)->get(['id', 'name']);
return Brand::whereIntegerInRaw('id', $brands)->get(['id', 'name']);
}
if ($this->shouldFilterByCollection()) {
$brands = Collection::query()->find($this->request->collection_id)->products()
$brands = Collection::find($this->request->collection_id)->products()
->where('products.is_visible', true)
->where('products.parent_id', null)
->where('products.stock', '>', 0)
->distinct('products.brand_id')
->pluck('products.brand_id');
return Brand::query()->whereIntegerInRaw('id', $brands)->get(['id', 'name']);
return Brand::whereIntegerInRaw('id', $brands)->get(['id', 'name']);
}
return Brand::query()->where('is_visible', true)->ordered()->get(['id', 'name']);
@@ -102,12 +103,36 @@ class FilterController extends Controller
->distinct('products.id')
->pluck('products.id');
return Category::query()
->distinct('categories.id')
->where('is_visible', true)
->join('product_has_relations', 'categories.id', '=', 'product_has_relations.productable_id')
->where('product_has_relations.productable_type', '=', 'category')
->whereIntegerInRaw('product_has_relations.product_id', $products)
return Category::where('is_visible', true)
->ordered()
->join('product_has_relations', 'categories.id', '=', 'product_has_relations.productable_id')
->where('product_has_relations.productable_type', '=', 'category')
->whereIntegerInRaw('product_has_relations.product_id', $products)
->get(['categories.id', 'categories.parent_id', 'categories.name'])
->unique('categories.id');
}
/**
* Categories for a resource
*/
private function categoriesFor($resource)
{
return DB::table('categories as c')
->select('c.id', 'c.parent_id', 'c.name')
->where('c.is_visible', true)
->whereExists(function ($query) {
$query->select(DB::raw(1))
->from('product_has_relations as phr_cat')
->join('products as p', 'p.id', '=', 'phr_cat.product_id')
->join('product_has_relations as phr_chan', 'phr_chan.product_id', '=', 'p.id')
->whereColumn('phr_cat.productable_id', 'c.id')
->where('phr_cat.productable_type', 'category')
->where('phr_chan.productable_type', 'channel')
->where('phr_chan.productable_id', 6)
->where('p.is_visible', true)
->whereNull('p.parent_id')
->where('p.stock', '>', 0);
})
->get()
->map(fn ($category) => [
'id' => $category->id,

0
artisan Executable file → Normal file
View File

View File

@@ -1,48 +0,0 @@
```html
<component
v-for="(rowField, j) in this.field.fields"
:key="j"
:is="`form-${rowField.component}`"
:field="rowField"
class="w-full"
/>
<Modal
:show="showModal"
size="7xl"
tabindex="-1"
role="dialog"
>
<div>
<ModalHeader v-text="'Headline of Modal'" class="bg-gray-100 dark:bg-gray-700" />
<ModalBody>
<div class="px-4 py-5 sm:p-6">
<ModalForm></ModalForm>
</div>
</ModalBody>
<ModalFooter>
<div class="flex items-center ml-auto">
<CancelButton
component="button"
type="button"
dusk="cancel-action-button"
class="ml-auto mr-3"
@click="onClose"
/>
<DefaultButton
type="submit"
@click="onSubmit"
>
Submit
</DefaultButton>
</div>
</ModalFooter>
</div>
</Modal>
```
"type": "composer",
"url": "https://nova.laravel.com"