diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php index d5dd3bb..5e273c7 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/BlogPostsApiController.php @@ -69,15 +69,15 @@ class BlogPostsApiController extends Controller }else if ($dataq->sections[$i]->section_type == "TPS\Birzha\Models\Product") { - $modified = $dataq->sections[$i]->section_type::where('type', $dataq->sections[$i]->product_type)->select('id', 'name', 'price', 'description', 'vendor_id', 'number_of_views', 'is_home')->with([ - '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', - 'place', - ])->limit(10)->get(); + $modified = $dataq->sections[$i]->section_type::where('type', $dataq->sections[$i]->product_type)->select('id', 'name', 'price', 'description', 'place_id', 'vendor_id', 'number_of_views', 'is_home', 'short_description')->with("place")->with([ + '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', + ])->limit(10)->get(); // $modified->makeHidden(['created_at', 'updated_at', 'deleted_at']); $product_section = array( "type"=> "product_section", + "header" => $dataq->sections[$i]->header, "contents"=> $modified ); $contents = array_merge($contents, array($product_section)); @@ -292,7 +292,7 @@ class BlogPostsApiController extends Controller //$data = User::find($id)->first; - $data = User::where('id', $id)->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'short_description', 'description', 'map', 'banner', 'is_instagram') + $data = User::where('id', $id)->select('id', 'name', 'email', 'username', 'type', 'logo', 'shop_title', 'slogan', 'work_time', 'short_description', 'description', 'map', 'banner', 'is_instagram', 'tiktok', 'instagram', 'site', 'qr') ->with(['categories' => function($q){ $q->with('translations:locale,model_id,attribute_data'); }]) diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php index 48ac42e..30b69f4 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/OrderApiController.php @@ -103,9 +103,35 @@ class OrderApiController extends Controller public function mySales(Request $request){ + $data = $request->all(); + + $validator = Validator::make($data, [ + 'order_id' => 'required', + ]); + + + + // $validator = $this->validateForm($data, $rules); + if($validator->fails()) { + return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validator->errors() ); + } + $currentUser = \JWTAuth::parseToken()->authenticate(); - $sales = VendorSales::where('vendor_id', $currentUser->id)->with(['order.user', 'product'])->orderBy('id', 'DESC')->paginate(15); + $sales = VendorSales::where('vendor_id', $currentUser->id)->where('order_id', $data["order_id"])->with(['order.user', 'product'])->orderBy('id', 'DESC')->paginate(15); + + + + return response()->json($sales, 200); + //return $this->helpers->apiArrayResponseBuilder(200, 'ok', [$orders]); + + } + + public function mySaleOrders(Request $request){ + + $currentUser = \JWTAuth::parseToken()->authenticate(); + + $sales = VendorSales::select('id', 'order_id', 'created_at', 'status')->where('vendor_id', $currentUser->id)->groupBy('order_id')->orderBy('id', 'DESC')->paginate(15); @@ -120,9 +146,9 @@ class OrderApiController extends Controller $currentUser = \JWTAuth::parseToken()->authenticate(); $counter = 0; - $sales = VendorSales::where('vendor_id', $currentUser->id)->where('status', 'new')->groupBy('order_id')->get(); + $sales = VendorSales::where('vendor_id', $currentUser->id)->where('status', 'new')->get(); + - $newOrders = array( "new_order_count" => count($sales), diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php index cedaff0..115c844 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ProductsApiController.php @@ -184,6 +184,7 @@ class ProductsAPIController extends Controller ->with([ 'translations:locale,model_id,attribute_data', 'images:attachment_id,attachment_type,disk_name,file_name', + 'place' ]) ->withCount(['comments as rating_avg' => function($query) { $query->select(DB::raw('avg(rating)')); @@ -266,7 +267,7 @@ class ProductsAPIController extends Controller $data = $this->Product::with([ 'translations:locale,model_id,attribute_data', 'images:attachment_id,attachment_type,disk_name,file_name', - 'vendor:id,name,surname,email,username,logo,banner', + 'vendor:id,name,surname,email,username,logo,banner,type', 'files', 'place', ]) //->withCount('comments')->withAvg('comments', 'rating') diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/TermsapiController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/TermsapiController.php index 8f35641..bd988f8 100644 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/TermsapiController.php +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/TermsapiController.php @@ -25,7 +25,7 @@ class TermsapiController extends Controller $inputData = $request->all(); $rules = [ - 'type' => 'required|in:about,privacy' + 'type' => 'required|in:about,privacy,success_prod_add' ]; $validator = Validator::make($inputData, $rules); @@ -41,6 +41,10 @@ class TermsapiController extends Controller case 'privacy': $data = $this->Term::privacy()->with('translations:locale,model_id,attribute_data')->get()->toArray(); break; + + case 'success_prod_add': + $data = $this->Term::ProdAdd()->with('translations:locale,model_id,attribute_data')->get()->toArray(); + break; default: # code... diff --git a/plugins/ahmadfatoni/apigenerator/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index f3ccae2..c76f646 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -52,6 +52,7 @@ Route::group(['prefix' =>'api/v1','namespace' =>'AhmadFatoni\ApiGenerator\Contro Route::post('make/order', 'OrderApiController@createOrder'); Route::get('my/orders', 'OrderApiController@myOrders'); + Route::get('vendor/sale/orders', 'OrderApiController@mySaleOrders'); Route::get('vendor/sales', 'OrderApiController@mySales'); Route::post('vendor/confirm/order', 'OrderApiController@confirmOrder'); Route::get('check/vendor/sales', 'OrderApiController@checkVendorSales'); diff --git a/plugins/tps/birzha/models/Product.php b/plugins/tps/birzha/models/Product.php index d42b2ec..86013ef 100644 --- a/plugins/tps/birzha/models/Product.php +++ b/plugins/tps/birzha/models/Product.php @@ -53,9 +53,9 @@ class Product extends Model ]; public $belongsTo = [ - 'place' => City::class, + //'place' => City::class, 'order_item' => OrderItems::class, - //'measure' => ['TPS\Birzha\Models\Measure','key' => 'measure_id'], + 'place' => ['TPS\Birzha\Models\City','key' => 'place_id'], //'currency' => ['TPS\Birzha\Models\Currency'], //'payment_term' => ['TPS\Birzha\Models\Term','key' => 'payment_term_id'], //'delivery_term' => ['TPS\Birzha\Models\Term','key' => 'delivery_term_id'], diff --git a/plugins/tps/birzha/models/Term.php b/plugins/tps/birzha/models/Term.php index 474e95c..2312736 100644 --- a/plugins/tps/birzha/models/Term.php +++ b/plugins/tps/birzha/models/Term.php @@ -41,4 +41,8 @@ class Term extends Model public function scopePrivacy($query){ return $query->where('type','privacy'); } + + public function scopeProdAdd($query){ + return $query->where('type','success_prod_add'); + } } diff --git a/plugins/tps/birzha/models/term/fields.yaml b/plugins/tps/birzha/models/term/fields.yaml index 8b4f5ac..ff7f078 100644 --- a/plugins/tps/birzha/models/term/fields.yaml +++ b/plugins/tps/birzha/models/term/fields.yaml @@ -9,6 +9,7 @@ fields: options: about: About privacy: 'Privacy Policy' + success_prod_add: 'Success prod Add' span: auto required: 1 type: balloon-selector