main
This commit is contained in:
Executable
+64
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Http\Controllers\Admin\PriceController;
|
||||
use App\Models\Cnt;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class Price extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'price: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()
|
||||
{
|
||||
$service = Http::
|
||||
withHeaders([
|
||||
'accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ohxsrbjagqvbt0glaygt'
|
||||
])->get('https://studio.persianapi.com/index.php/web-service/common/gold-currency-coin?format=json&limit=30&page=1')
|
||||
->json();
|
||||
$list = [];
|
||||
if(isset($service['result'])){
|
||||
foreach ($service['result'] as $item){
|
||||
if ($item['key']== 137120 || $item['key']==137119) {
|
||||
$list[] = $item;
|
||||
if ($item['key']== 137120){
|
||||
(new PriceController())->store(new Request(["price"=>$item['price']]));
|
||||
}
|
||||
}
|
||||
}
|
||||
Cnt::where('key','price')->update(['value_json'=>$list]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user