Viewing file: SyncProduct.php (1.92 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Jobs;
use App\Models\Category; use App\Models\Item; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str;
class SyncProduct implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $timeout=60 * 3; public $response; /** * Create a new job instance. * * @return void */
public function __construct($response_data) { $this->response = $response_data; }
/** * Execute the job. * * @return void */ public function handle() {
try { $item = $this->response;
if($item) {
$it = Item::updateOrCreate( [ 'name' => $item->name, 'code' => $item->code ], [ // 'name' => $item->name, 'slug' => Str::slug($item->name, '-'), // 'code' => $item->code, 'status' => $item->status, 'category_code' => $item->category_code, 'country_code' => $item->country_code, 'provider_code' => $item->provider_code, 'process_time' => $item->process_time, 'price' => $item->price, ] ); }
return;
}catch(\Exception $e){ Log::error($e->getMessage());
return; }
}
public function failed($exception) { Log::info($exception);
} }
|