From 01a057bfc8797ca4df22d6676bcd13139b6e49d0 Mon Sep 17 00:00:00 2001 From: Jing Li Date: Wed, 30 Aug 2023 14:09:15 +0800 Subject: [PATCH] Update --- app/Console/Commands/BiAng/DeviceLogSyncCommand.php | 7 ++++++- app/Http/Resources/WormPhotoResource.php | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php index b90a0ab..8a03bc7 100644 --- a/app/Console/Commands/BiAng/DeviceLogSyncCommand.php +++ b/app/Console/Commands/BiAng/DeviceLogSyncCommand.php @@ -148,8 +148,13 @@ class DeviceLogSyncCommand extends Command if ($ext = pathinfo($item['url'], PATHINFO_EXTENSION)) { $name .= ".{$ext}"; } + $path = "{$dir}/{$name}"; - $disk->put($path, file_get_contents($item['url'])); + + $disk = Storage::disk('public'); + if (! $disk->exists($path)) { + $disk->put($path, file_get_contents($item['url'])); + } WormPhoto::firstOrCreate([ 'device_id' => $device->id, diff --git a/app/Http/Resources/WormPhotoResource.php b/app/Http/Resources/WormPhotoResource.php index 773bd26..d46ea9c 100644 --- a/app/Http/Resources/WormPhotoResource.php +++ b/app/Http/Resources/WormPhotoResource.php @@ -11,7 +11,7 @@ class WormPhotoResource extends JsonResource return [ 'id' => $this->id, 'url' => $this->image_url, - 'time' => $this->created_at->toDateTimeString(), + 'time' => $this->uploaded_at->toDateTimeString(), ]; } }