-2
私はURLを含む 'ical'というフィールドを持っていますが、機能を実行するにはurlを使ってファイルをダウンロードしますが、フィールドが空の場合はその行を無視します。現時点では、各行のファイルをダウンロードし、URLがあれば正しいデータで埋められますが、フィールドが空の場合はファイルをダウンロードしましたが、もちろん空ですが、代わりに完全に空の場合はその行を無視します。Laravelはフィールドが空でない場合にのみダウンロードします
<?php
namespace App\Console\Commands;
use App\Entity;
use Illuminate\Console\Command;
use Ixudra\Curl\Facades\Curl;
class DownloadIcal extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ical:download';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Download all ICAL files from ical field in businesses database';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$entities = Entity::pluck('ical', 'id');
foreach ($entities as $entityID => $entityIcal) {
$response = Curl::to($entityIcal)
->download('public/ical/'.$entityID.'.ics');
$this->info("ICal Retrieved");
}
}
}
この 'foreachの($として$実体実体識別子=> $ entityIcal){ \t($ entityIcal){ \t $応答=カール:: \t($ entityIcal)の場合を試してみてくださいpublic/ical/'.$ entityID。'。ics '); \t $ this-> info( "ICal Retrieved"); \t} } '!! – Maraboc