Compare commits

...

3 Commits

Author SHA1 Message Date
Mekan1206
62f8deb51f WIP 2026-05-02 16:16:56 +05:00
Mekan1206
40cac31648 fix 2026-05-02 12:56:32 +05:00
Mekan1206
6617c8bd27 WIP 2026-05-02 12:55:20 +05:00
4 changed files with 25 additions and 19 deletions

View File

@@ -62,29 +62,29 @@ class FilterController extends Controller
private function brands() private function brands()
{ {
if ($this->shouldFilterByBrand()) { if ($this->shouldFilterByBrand()) {
return Brand::where('id', $this->request->brand_id)->get(['id', 'name']); return Brand::query()->where('id', $this->request->brand_id)->get(['id', 'name']);
} }
if ($this->shouldFilterByCategory()) { if ($this->shouldFilterByCategory()) {
$brands = Category::find($this->request->category_id)->products() $brands = Category::query()->find($this->request->category_id)->products()
->where('products.is_visible', true) ->where('products.is_visible', true)
->where('products.parent_id', null) ->where('products.parent_id', null)
->where('products.stock', '>', 0) ->where('products.stock', '>', 0)
->distinct('products.brand_id') ->distinct('products.brand_id')
->pluck('products.brand_id'); ->pluck('products.brand_id');
return Brand::whereIntegerInRaw('id', $brands)->get(['id', 'name']); return Brand::query()->whereIntegerInRaw('id', $brands)->get(['id', 'name']);
} }
if ($this->shouldFilterByCollection()) { if ($this->shouldFilterByCollection()) {
$brands = Collection::find($this->request->collection_id)->products() $brands = Collection::query()->find($this->request->collection_id)->products()
->where('products.is_visible', true) ->where('products.is_visible', true)
->where('products.parent_id', null) ->where('products.parent_id', null)
->where('products.stock', '>', 0) ->where('products.stock', '>', 0)
->distinct('products.brand_id') ->distinct('products.brand_id')
->pluck('products.brand_id'); ->pluck('products.brand_id');
return Brand::whereIntegerInRaw('id', $brands)->get(['id', 'name']); return Brand::query()->whereIntegerInRaw('id', $brands)->get(['id', 'name']);
} }
return Brand::query()->where('is_visible', true)->ordered()->get(['id', 'name']); return Brand::query()->where('is_visible', true)->ordered()->get(['id', 'name']);
@@ -102,11 +102,18 @@ class FilterController extends Controller
->distinct('products.id') ->distinct('products.id')
->pluck('products.id'); ->pluck('products.id');
return Category::where('is_visible', true)->ordered()->join('product_has_relations', 'categories.id', '=', 'product_has_relations.productable_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') ->where('product_has_relations.productable_type', '=', 'category')
->whereIntegerInRaw('product_has_relations.product_id', $products) ->whereIntegerInRaw('product_has_relations.product_id', $products)
->get(['id', 'parent_id', 'name']) ->get()
->unique('categories.id'); ->map(fn ($category) => [
'id' => $category->id,
'parent_id' => $category->parent_id,
'name' => $category->name,
]);
} }
/** /**

View File

@@ -14,7 +14,9 @@ class OrderPaymentController extends Controller
public function index(): JsonResponse public function index(): JsonResponse
{ {
return response()->rest( return response()->rest(
PaymentType::all(['id', 'name']) PaymentType::query()
->where('is_enabled', true)
->get(['id', 'name', 'is_enabled'])
->map(fn ($paymentType) => [ ->map(fn ($paymentType) => [
'id' => $paymentType->id, 'id' => $paymentType->id,
'name' => $paymentType->name, 'name' => $paymentType->name,

View File

@@ -13,8 +13,6 @@ use App\Models\Ecommerce\Product\Review\Review;
use App\Models\Post\User\UserDoc; use App\Models\Post\User\UserDoc;
use App\Models\System\Settings\Location\UserAddress; use App\Models\System\Settings\Location\UserAddress;
use App\Repositories\System\Cache\CacheRepository; use App\Repositories\System\Cache\CacheRepository;
use BasementChat\Basement\Contracts\User as BasementUserContract;
use BasementChat\Basement\Traits\HasPrivateMessages;
use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
@@ -25,12 +23,11 @@ use Laravel\Sanctum\HasApiTokens;
use Spatie\DeletedModels\Models\Concerns\KeepsDeletedModels; use Spatie\DeletedModels\Models\Concerns\KeepsDeletedModels;
use Spatie\Permission\Traits\HasRoles; use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable implements BasementUserContract class User extends Authenticatable
{ {
use HasApiTokens; use HasApiTokens;
use HasEcommerceChannels; use HasEcommerceChannels;
use HasFactory; use HasFactory;
use HasPrivateMessages;
use HasRoles; use HasRoles;
use HasSchemalessAttributes; use HasSchemalessAttributes;
use InteractsWithNova; use InteractsWithNova;

View File

@@ -101,12 +101,12 @@ Route::get('filters', [FilterController::class, 'index']);
// Global orders... // Global orders...
Route::post('global-order', [GlobalOrderController::class, 'store']); Route::post('global-order', [GlobalOrderController::class, 'store']);
Route::middleware('auth:sanctum')->group(function () { // Route::middleware('auth:sanctum')->group(function () {
Route::get('/chat/contacts', [ChatController::class, 'contacts']); // Route::get('/chat/contacts', [ChatController::class, 'contacts']);
Route::get('/chat/messages/{conversation}', [ChatController::class, 'messages']); // Route::get('/chat/messages/{conversation}', [ChatController::class, 'messages']);
Route::post('/chat/start', [ChatController::class, 'start']); // Route::post('/chat/start', [ChatController::class, 'start']);
Route::post('/chat/send', [ChatController::class, 'send']); // Route::post('/chat/send', [ChatController::class, 'send']);
}); // });
Route::middleware(['auth:sanctum', 'banned'])->group(function () { Route::middleware(['auth:sanctum', 'banned'])->group(function () {
// Profile... // Profile...