2026-01-24 14:03:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
2026-03-10 15:39:30 +03:30
|
|
|
use Illuminate\Support\Facades\Http;
|
2026-01-24 14:03:11 +00:00
|
|
|
|
|
|
|
|
class Cnt extends Model
|
|
|
|
|
{
|
|
|
|
|
use HasFactory;
|
|
|
|
|
protected $table = 'const';
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'key',
|
|
|
|
|
'title_fa',
|
|
|
|
|
'value',
|
|
|
|
|
'value_json'
|
|
|
|
|
];
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'value_json'=>'array'
|
|
|
|
|
];
|
2026-03-10 15:39:30 +03:30
|
|
|
public function goldir_login(){
|
|
|
|
|
$mobile = self::where('key', 'goldir_mobile')->value('value');
|
|
|
|
|
$password = self::where('key', 'goldir_password')->value('value');
|
|
|
|
|
|
2026-04-01 10:58:08 +00:00
|
|
|
$goldir = Http::withOptions([
|
|
|
|
|
'curl' => [
|
|
|
|
|
CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
|
|
|
|
|
CURLOPT_TCP_FASTOPEN => 1,
|
|
|
|
|
]
|
|
|
|
|
])
|
|
|
|
|
->withoutVerifying()
|
|
|
|
|
->post('https://gold.ir/server/auth/login', [
|
2026-03-10 15:39:30 +03:30
|
|
|
'mobile' => $mobile,
|
|
|
|
|
'password' => $password,
|
|
|
|
|
'provider' => 'customer',
|
|
|
|
|
'type_app' => 'client',
|
|
|
|
|
])->json();
|
|
|
|
|
|
|
|
|
|
Cnt::where('key', 'goldir')->update([
|
|
|
|
|
'value' => $goldir['access_token'],
|
|
|
|
|
'updated_at' => now()
|
|
|
|
|
]);
|
|
|
|
|
return $goldir['access_token'];
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-24 14:03:11 +00:00
|
|
|
}
|