Improve uploader client connection and diagnostics
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Photobooth\PhotoboothConnectRedeemRequest;
|
||||
use App\Models\Event;
|
||||
use App\Services\Photobooth\PhotoboothConnectCodeService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
@@ -33,6 +34,7 @@ class PhotoboothConnectController extends Controller
|
||||
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'event_name' => $this->resolveEventName($event),
|
||||
'upload_url' => route('api.v1.photobooth.upload'),
|
||||
'username' => $setting->username,
|
||||
'password' => $setting->password,
|
||||
@@ -42,4 +44,27 @@ class PhotoboothConnectController extends Controller
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
private function resolveEventName(?Event $event): ?string
|
||||
{
|
||||
if (! $event) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$name = $event->name;
|
||||
|
||||
if (is_string($name) && trim($name) !== '') {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (is_array($name)) {
|
||||
foreach ($name as $value) {
|
||||
if (is_string($value) && trim($value) !== '') {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $event->slug ?: null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user