From 5bb4a36f8760aa88436f4d6556a7e48325523d35 Mon Sep 17 00:00:00 2001 From: gholak tala Date: Sun, 17 May 2026 16:27:50 +0000 Subject: [PATCH] NASER & LOTFI dynamic connect to hamkar app --- app/Http/Controllers/Site/ReportController.php | 12 ++++++++---- app/Models/Cnt.php | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/Site/ReportController.php b/app/Http/Controllers/Site/ReportController.php index 10725cf..1153c53 100644 --- a/app/Http/Controllers/Site/ReportController.php +++ b/app/Http/Controllers/Site/ReportController.php @@ -156,7 +156,9 @@ class ReportController extends Controller $open_buy = true; $open_sell = true; if($gold_ir_price == 'true' && !$closed){ + $goldir_price = 0; + $goldir_base_url=$this->Config('goldir_base_url')??'https://gold.ir'; try{ $goldir = Http::timeout(7)->withOptions([ 'curl' => [ @@ -166,16 +168,16 @@ class ReportController extends Controller ]) ->withoutVerifying() // غیرفعال کردن بررسی SSL (برای تست سرعت) ->withToken(Cnt::where('key', 'goldir')->first()['value']) - ->get('https://gold.ir/server/customer/product/list')->json(); + ->get($goldir_base_url.'/server/customer/product/list')->json(); if((isset($goldir['message']) && $goldir['message'] == 'no authorised') || $goldir == null){ $cnt = new Cnt(); $goldir = Http::timeout(2)->withToken($cnt->goldir_login()) - ->get('https://gold.ir/server/customer/product/list')->json(); + ->get($goldir_base_url.'/server/customer/product/list')->json(); } $customPrice= []; $collection = collect($goldir); - $lp = $collection->firstWhere('id', 40); + $lp = $collection->firstWhere('id', $this->Config('hamkar_product_id')); // foreach ($goldir as $lp) { // if ($lp['id'] == 40) { @@ -208,7 +210,9 @@ class ReportController extends Controller }else{ Cnt::where('key', 'goldir_closed')->update(['value' => "false"]); } - } catch (\Exception $e) {$goldir_price = 0;} + } catch (\Exception $e) { + echo $e->getMessage(); + $goldir_price = 0;} } if($main_product_price == 'true' && !$closed){ diff --git a/app/Models/Cnt.php b/app/Models/Cnt.php index 0fa9ffc..d312a1e 100644 --- a/app/Models/Cnt.php +++ b/app/Models/Cnt.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Http\Controllers\Controller; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Http; @@ -22,6 +23,7 @@ class Cnt extends Model public function goldir_login(){ $mobile = self::where('key', 'goldir_mobile')->value('value'); $password = self::where('key', 'goldir_password')->value('value'); + $goldir_base_url=Controller::Config('goldir_base_url')??'https://gold.ir'; $goldir = Http::withOptions([ 'curl' => [ @@ -30,7 +32,7 @@ class Cnt extends Model ] ]) ->withoutVerifying() - ->post('https://gold.ir/server/auth/login', [ + ->post($goldir_base_url.'/server/auth/login', [ 'mobile' => $mobile, 'password' => $password, 'provider' => 'customer',