diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php index fd1d087..668482d 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php @@ -115,7 +115,7 @@ class BlogPostsApiController extends Controller $products->map(function ($product) { $image = new Image($product->images[0]->path); - $product->images[0]->compressed_image = $image->resize([ 'quality' => 50])->getCachedImagePath(true); + $product->images[0]->compressed_image = $image->resize(510)->getCachedImagePath(true); return $product; //foreach($product->images as $compressImage){ @@ -136,17 +136,49 @@ class BlogPostsApiController extends Controller $data = $request->all(); - + $catIds = $this->onGetCategorySubs($data["category"]); - $accounts = Category::select("id","name", "icon", "is_file_category", "primary_key")->where('id', $data["category"]) - ->with(["users" => function($q){ - $q->where("type", "!=", "simple"); - }]) + $cats = Category::whereIn("id", $catIds)->with("subs")->get(); + + + + foreach($cats as $cat) { + foreach($cat->subs as $sub) { + array_unshift($catIds, $sub->id); + } + } + + $accounts = Category::select("id","name", "icon", "is_file_category", "primary_key") + ->where('id', $data["category"]) + //->whereIn('id', $cats) + ->with('users') + //->whereHas('users.categories', function($q) use($cats){ + // $q->whereIn('id', $cats); + //}) + + //->with(["users" => function($q) use($cats){ + // $q->where("type", "!=", "simple") + // ->with('categories') + // ->whereHas('categories', function($qq) use($cats){ + // $qq->whereIn('id', $cats); + // }); + //}]) ->get(); + + $userAccounts = User::where('type', '!=', 'simple') + ->whereHas('categories', function($q) use($catIds){ + $q->whereIn('category_id', $catIds); + }) + ->get(); - $banners = Category::select("id","name", "icon", "is_file_category", "primary_key")->where('id', $data["category"])->with(["users" => function($q){ - $q->where("is_category", 1)->select("category_id", "user_id", "logo", "banner", "is_instagram"); - }])->get(); + $accounts[0]->users = $userAccounts; + + $banners = Category::select("id","name", "icon", "is_file_category", "primary_key") + ->where('id', $data["category"]) + ->with(["users" => function($q){ + $q->where("is_category", 1)->select("category_id", "user_id", "logo", "banner", "is_instagram"); + }]) + ->get(); $data = array( "path" => $path, "accounts" => $accounts, @@ -196,7 +228,7 @@ class BlogPostsApiController extends Controller 'translations:locale,model_id,attribute_data', 'images:attachment_id,attachment_type,disk_name,file_name', 'vendor:id,name,email,type,logo,banner,shop_title,slogan,is_instagram,web2', - ])->limit(10)->get(); + ])->orderBy('ends_at', 'DESC')->limit(20)->get(); // $modified->makeHidden(['created_at', 'updated_at', 'deleted_at']); $product_section = array( "type"=> "product_section", @@ -371,7 +403,7 @@ class BlogPostsApiController extends Controller $favourite->map(function ($fav) { $image = new Image($fav->product->images[0]->path); - $fav->product->images[0]->compressed_image = $image->resize([ 'quality' => 50])->getCachedImagePath(true); + $fav->product->images[0]->compressed_image = $image->resize(510)->getCachedImagePath(true); return $fav; }); @@ -405,7 +437,7 @@ class BlogPostsApiController extends Controller $data->map(function ($product) { $image = new Image($product->images[0]->path); - $product->images[0]->compressed_image = $image->resize([ 'quality' => 50])->getCachedImagePath(true); + $product->images[0]->compressed_image = $image->resize(510)->getCachedImagePath(true); return $product; //foreach($product->images as $compressImage){ @@ -471,6 +503,7 @@ class BlogPostsApiController extends Controller $all = array( "id" => 0, "name"=> "Hemmesi", + "icon" => "/not_found_img/placeholder.png" ); //array_unshift($data->categories, $all); diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php index a1b90d8..63cef68 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php @@ -306,7 +306,7 @@ class OrderApiController extends Controller $currentUser = \JWTAuth::parseToken()->authenticate(); $counter = 0; - $sales = VendorSales::where('vendor_id', $currentUser->id)->where('status', 'new')->get(); + $sales = VendorSales::where('vendor_id', $currentUser->id)->where('status', 'new')->groupBy('order_id')->get(); @@ -336,6 +336,7 @@ class OrderApiController extends Controller //dd($data); $currentUser = \JWTAuth::parseToken()->authenticate(); $vendorOrders = VendorSales::where('order_id', $data["order_id"])->get(); + $order = Orders::where('id', $data["order_id"])->first(); if((count($vendorOrders) != 0) && ($vendorOrders[0]->vendor_id == $currentUser->id)){ @@ -345,6 +346,9 @@ class OrderApiController extends Controller $vendorOrders[$i]->save(); } + + $order->status = "completed"; + $order->save(); } diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php index 6b9ee33..5f1d069 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php @@ -55,7 +55,7 @@ class ProductsAPIController extends Controller $products->map(function ($product) { $image = new Image($product->images[0]->path); - $product->images[0]->compressed_image = $image->resize([ 'quality' => 50])->getCachedImagePath(true); + $product->images[0]->compressed_image = $image->resize(510)->getCachedImagePath(true); return $product; }); @@ -304,12 +304,12 @@ class ProductsAPIController extends Controller } - $data = $query ? $query->orderBy('id', "DESC")->orderBy('ends_at', $sortOrder)->paginate($perPage) : null; + $data = $query ? $query->orderBy('created_at', "DESC")->orderBy('id', "DESC")->paginate($perPage) : null; $data->map(function ($product) { $image = new Image($product->images[0]->path); - $product->images[0]->compressed_image = $image->resize(500)->getCachedImagePath(true); + $product->images[0]->compressed_image = $image->resize(510)->getCachedImagePath(true); return $product; @@ -681,7 +681,7 @@ class ProductsAPIController extends Controller if($product){ - $product->ends_at = $currentDateFormat; + $product->created_at = $currentDateFormat; $product->save(); diff --git a/plugins/rainlab/user/models/User.php b/plugins/rainlab/user/models/User.php index 380b440..ed21fa3 100644 --- a/plugins/rainlab/user/models/User.php +++ b/plugins/rainlab/user/models/User.php @@ -45,8 +45,6 @@ class User extends UserBase 'categories' => [ 'TPS\Birzha\Models\Category', 'table'=>'tps_birzha_users_categories', - 'delete' => true, - 'softDelete' => true ], ]; @@ -58,14 +56,14 @@ class User extends UserBase ]; public $hasMany = [ - 'products' => ['TPS\Birzha\Models\Product', 'key' => 'vendor_id', 'softDelete' => true], + 'products' => ['TPS\Birzha\Models\Product', 'key' => 'vendor_id'], 'transactions' => ['TPS\Birzha\Models\Transaction', 'softDelete' => true], 'exchangerequests' => ['TPS\Birzha\Models\Exchangerequest', 'softDelete' => true], - 'sliders' => ['TPS\Birzha\Models\UserSliders', 'softDelete' => true], - 'favourites' => ['TPS\Birzha\Models\Favourites', 'softDelete' => true, 'table' => 'tps_birzha_favourites'], + 'sliders' => ['TPS\Birzha\Models\UserSliders'], + 'favourites' => ['TPS\Birzha\Models\Favourites', 'table' => 'tps_birzha_favourites'], 'comments' => ['TPS\Birzha\Models\Comment','table' => 'tps_birzha_comments'], 'orders' => ['TPS\Birzha\Models\Orders','table' => 'tps_birzha_orders'], - 'vendor_sales' => ['TPS\Birzha\Models\VendorSales', 'key' => 'vendor_id', 'softDelete' => true], + 'vendor_sales' => ['TPS\Birzha\Models\VendorSales', 'key' => 'vendor_id'], 'messages' => ['TPS\Birzha\Models\Message', 'key' => 'reciver_id', 'softDelete' => true], ]; diff --git a/plugins/rainlab/user/models/user/fields.yaml b/plugins/rainlab/user/models/user/fields.yaml index 2445de0..ccc3aca 100644 --- a/plugins/rainlab/user/models/user/fields.yaml +++ b/plugins/rainlab/user/models/user/fields.yaml @@ -127,6 +127,7 @@ tabs: label: Kategoriýalar nameFrom: name descriptionFrom: description + scope: userCategory span: auto type: relation tab: Kategoriyalar diff --git a/plugins/tps/birzha/components/CategoryProfile.php b/plugins/tps/birzha/components/CategoryProfile.php index 93cfcb3..05ff56c 100644 --- a/plugins/tps/birzha/components/CategoryProfile.php +++ b/plugins/tps/birzha/components/CategoryProfile.php @@ -22,6 +22,7 @@ class CategoryProfile extends ComponentBase public $subcategories; public $categories; public $cities; + public $categoryUsers; public function componentDetails() { return [ @@ -49,6 +50,7 @@ class CategoryProfile extends ComponentBase public function onRun() { $this->users = $this->getCategoryUsers(); $this->category = $this->getCategory(); + $this->categoryUsers = $this->category->users; $this->subcategories = $this->getSubs(); $this->categories = $this->getCategories(); $this->cities = $this->getCities(); @@ -88,7 +90,7 @@ class CategoryProfile extends ComponentBase protected function getCategoryUsers(){ $cSlug = $this->property('categorySlug'); $category = Category::where('slug', $cSlug)->first(); - $users = $category ? $category->users()->get() : null; + $users = $category ? $category->users()->where('is_category', 1)->get() : null; return $users; } diff --git a/plugins/tps/birzha/components/categoryprofile/default.htm b/plugins/tps/birzha/components/categoryprofile/default.htm index fb2e5b9..9455590 100644 --- a/plugins/tps/birzha/components/categoryprofile/default.htm +++ b/plugins/tps/birzha/components/categoryprofile/default.htm @@ -1,6 +1,7 @@ {% set category = __SELF__.category %} {% set categories = __SELF__.categories %} {% set users = __SELF__.users %} +{% set categoryUsers = __SELF__.categoryUsers %} {% set subs = __SELF__.subcategories %} {% set cities = __SELF__.cities %} {% set counter = 0 %} @@ -24,16 +25,41 @@ + + + + + +