Add support for seeding nests and eggs
This commit is contained in:
parent
99aceaca38
commit
f8c89f8331
21 changed files with 862 additions and 18 deletions
|
@ -69,10 +69,12 @@ class EggShareController extends Controller
|
|||
*/
|
||||
public function export(Egg $egg): Response
|
||||
{
|
||||
$filename = trim(preg_replace('/[^\w]/', '-', kebab_case($egg->name)), '-');
|
||||
|
||||
return response($this->exporterService->handle($egg->id), 200, [
|
||||
'Content-Transfer-Encoding' => 'binary',
|
||||
'Content-Description' => 'File Transfer',
|
||||
'Content-Disposition' => 'attachment; filename=egg-' . kebab_case($egg->name) . '.json',
|
||||
'Content-Disposition' => 'attachment; filename=egg-' . $filename . '.json',
|
||||
'Content-Type' => 'application/json',
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class EggImporterService
|
|||
*/
|
||||
public function handle(UploadedFile $file, int $nest): Egg
|
||||
{
|
||||
if (! $file->isValid() || ! $file->isFile()) {
|
||||
if ($file->getError() !== UPLOAD_ERR_OK || ! $file->isFile()) {
|
||||
throw new InvalidFileUploadException(trans('exceptions.nest.importer.file_error'));
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class EggUpdateImporterService
|
|||
*/
|
||||
public function handle(int $egg, UploadedFile $file)
|
||||
{
|
||||
if (! $file->isValid() || ! $file->isFile()) {
|
||||
if ($file->getError() !== UPLOAD_ERR_OK || ! $file->isFile()) {
|
||||
throw new InvalidFileUploadException(trans('exceptions.nest.importer.file_error'));
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue