Updates
This commit is contained in:
parent
05c4610654
commit
ac3a36e489
@ -35,8 +35,9 @@ class ListEggs extends ListRecords
|
||||
/** @var EggImporterService $eggImportService */
|
||||
$eggImportService = resolve(EggImporterService::class);
|
||||
|
||||
foreach ($eggFile as $file) {
|
||||
try {
|
||||
$eggImportService->handle($eggFile);
|
||||
$eggImportService->handle($file);
|
||||
} catch (Exception $exception) {
|
||||
Notification::make()
|
||||
->title('Egg Import Failed')
|
||||
@ -47,6 +48,7 @@ class ListEggs extends ListRecords
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Notification::make()
|
||||
->title('Egg Import Success')
|
||||
|
@ -5,6 +5,7 @@ namespace App\Services\Eggs\Sharing;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Illuminate\Support\Arr;
|
||||
use App\Models\Egg;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use App\Models\EggVariable;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use App\Services\Eggs\EggParserService;
|
||||
@ -20,14 +21,11 @@ class EggImporterService
|
||||
*
|
||||
* @throws \App\Exceptions\Service\InvalidFileUploadException|\Throwable
|
||||
*/
|
||||
public function handle(array $files): array
|
||||
public function handle(UploadedFile $file): Egg
|
||||
{
|
||||
$eggs = [];
|
||||
|
||||
foreach ($files as $file) {
|
||||
$parsed = $this->parser->handle($file);
|
||||
|
||||
$egg = $this->connection->transaction(function () use ($parsed) {
|
||||
return $this->connection->transaction(function () use ($parsed) {
|
||||
$egg = (new Egg())->forceFill([
|
||||
'uuid' => Uuid::uuid4()->toString(),
|
||||
'author' => Arr::get($parsed, 'author'),
|
||||
@ -44,7 +42,4 @@ class EggImporterService
|
||||
return $egg;
|
||||
});
|
||||
}
|
||||
|
||||
return $eggs;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user