/
home
/
henzagold
/
server
/
app
/
Console
/
Commands
/
File Upload :
llllll
Current File: //home/henzagold/server/app/Console/Commands/GetGoldPriceForPwa.php
<?php namespace App\Console\Commands; use App\Models\ConfigStatic; use Illuminate\Console\Command; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Http; use Morilog\Jalali\Jalalian; class GetGoldPriceForPwa extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'pwa:price'; /** * The console command description. * * @var string */ protected $description = 'Command description'; /** * Create a new command instance. * * @return void */ public function __construct() { parent::__construct(); } /** * Execute the console command. * * @return int */ public function handle() { $tala_ir = (int)str_replace(',', '', Http::timeout(2)->get('https://www.tala.ir/ajax/price')->json()['gold']['gold_18k']['v']) * 10; if (!is_null($tala_ir)) { $service['uaj'] = Jalalian::forge(now())->format('Y/m/d - H:i:s'); // // // فیلتر کردن دادهها // $filtered = Arr::except($service, [7,8,9,10,20,21,22,23,24,25,26,27,28,29]); // تعریف آرایه با دادههای جدید $filtered['mesghal'] = [ "title" => "مثقاع طلا", "slug" => "mesghal", "p" => "206,460,000", "d" => "0", "dp" => "0.0000", "dt" => "", "h" => "206,460,000", "l" => "202,910,000", "t" => "1403-09-21 12:00:00", "updated_at" => "2024-10-10 20:11:12", "uaj" => "1403/09/25 - 12:13" ]; $filtered['geram18'] = [ "title" => "طلای 18 عیار", "slug" => "geram18", "p" => number_format($tala_ir), "d" => "0", "dp" => "0.0000", "dt" => "", "h" => number_format($tala_ir), "l" => number_format($tala_ir), "t" => $service['uaj'], "updated_at" => "2024-10-10 20:11:03", "uaj" => $service['uaj'] ]; $filtered['geram24'] = [ "title" => "طلای 24 عیار", "slug" => "geram24", "p" => "63,542,200", "d" => "0", "dp" => "0.0000", "dt" => "", "h" => "63,542,200", "l" => "62,449,600", "t" => "1403-09-21 12:00:00", "updated_at" => "2024-10-10 20:11:03", "uaj" => "1403/09/25 - 12:12" ]; // dd($filtered); // اینجا را میتوانید حذف کنید پس از بررسی // بهروزرسانی مقدار در پایگاه داده ConfigStatic::where('key','gold_price_pwa')->update(['val' => $filtered]); ConfigStatic::where('key', 'gold_price')->update(['val' => json_encode($filtered)]); return ConfigStatic::where('key','gold_price')->get(); } } // public function handle() // { // $service = Http::get('https://api.ratebox.ir/apijson.php?token='.env('WEBSERVICE_TOKEN')) // ->json(); // if (!is_null($service)){ // $service['uaj'] = Jalalian::forge(now())->format('Y/m/d - H:i:s'); // $filtered =Arr::except($service, [7,8,9,10,20,21,22,23,24,25,26,27,28,29]); // ConfigStatic::where('key','gold_price_pwa')->update(['val' => $filtered]); // } // // } }
Copyright ©2k19 -
Hexid
|
Tex7ure