ใน Laravel-5.8 ของฉัน ฉันมีงาน cron กำลังทำงานอยู่
public function handle()
{
$client = new Client();
$res = $client->request('GET','https://api.laravel.com/my-workers', [
'query' => ['key' => 'kkdfhfn7755222']
])->getBody();
$clientdatas = json_decode($res->getContents(), true);
foreach($clientdatas as $clientdata)
{
$testing = HrTesting::updateOrCreate([
'testing_name' => $clientdata['testing_location']
],
[
'company_id' => 1,
]);
}
}
ฉันพบว่า $clientdata['testing_location'] เป็นโมฆะ แต่ก็ยังสร้าง / อัปเดตในตาราง
ฉันจะบอกได้อย่างไรว่าเมื่อเป็นโมฆะก็ไม่ควรดำเนินการใดๆ
ขอบคุณ
if($clientdata['testing_location'] === null) { continue; }
ภายในforeach
loop ใช่ไหม? :) - person Oleg Nurutdinov   schedule 21.07.2020