/
var
/
www
/
html
/
plugin-techloyce
/
app
/
Console
/
Commands
/
Upload File
HOME
<?php namespace App\Console\Commands; use Carbon\Carbon; use GuzzleHttp\Client; use Illuminate\Console\Command; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\DB; use App\Models\AuthToken; use App\Http\Controllers\Telephony\Providers\RingCentralController; class RingHookUpdated extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'update:ringHook'; /** * 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 mixed */ public function handle(){ $user = AuthToken::where('app', 'RingCentral')->get(); Self::updateHooks($user); } private static function updateHooks($user){ try { foreach ($user as $row) { $hook_data = ""; $hook_data = !empty($row->webhook)? $row->webhook : ""; if($hook_data != "" || $hook_data != null){ $hook_data = json_decode($hook_data, 1); $hook_id = $hook_data['hook_id']; $token = RingCentralController::get_access_token($row); $hook_response = RingCentralController::get_subscription_by_id($token['access_token'], $hook_id); if(isset($hook_response->id)){ $expirationTime = $hook_response->expirationTime; if(date('Y-m-d') > $expirationTime){ $response = RingCentralController::update_subscription($token['access_token'], $hook_id); } } } } } catch (\Exception $e){ Log::info($e); } } }