10-04-2026
This commit is contained in:
parent
4d6b4930b2
commit
4bb89aad8c
836 changed files with 52961 additions and 5950 deletions
54
app/Http/Controllers/Api/CabinetTabletController.php
Normal file
54
app/Http/Controllers/Api/CabinetTabletController.php
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\CabinetTabletSetting;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class CabinetTabletController extends Controller
|
||||
{
|
||||
/**
|
||||
* Full status response for the info-tablet.
|
||||
*/
|
||||
public function status(): JsonResponse
|
||||
{
|
||||
$settings = CabinetTabletSetting::current();
|
||||
$computed = $settings->computeStatus();
|
||||
|
||||
return response()->json([
|
||||
'store_status' => $computed['status'],
|
||||
'today_close' => $computed['today_close'],
|
||||
'next_open' => $computed['next_open'],
|
||||
'notice_headline' => $settings->notice_headline,
|
||||
'notice_subtext' => $settings->notice_subtext,
|
||||
'override_open_today' => $settings->override_open_today,
|
||||
'override_close_today' => $settings->override_close_today,
|
||||
'next_appointment' => [
|
||||
'date' => $settings->next_appointment_date?->format('Y-m-d'),
|
||||
'time' => $settings->next_appointment_time,
|
||||
],
|
||||
'hours' => $settings->getHoursArray(),
|
||||
'contact' => [
|
||||
'phone' => $settings->contact_phone,
|
||||
'email' => $settings->contact_email,
|
||||
],
|
||||
'updated_at' => $settings->updated_at?->toIso8601String(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lightweight check – returns the timestamp and current computed status
|
||||
* so the tablet can detect both settings changes and time-based open/close transitions.
|
||||
*/
|
||||
public function check(): JsonResponse
|
||||
{
|
||||
$settings = CabinetTabletSetting::current();
|
||||
$computed = $settings->computeStatus();
|
||||
|
||||
return response()->json([
|
||||
'updated_at' => $settings->updated_at?->toIso8601String(),
|
||||
'store_status' => $computed['status'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
151
app/Http/Controllers/Api/DisplayVersionApiController.php
Normal file
151
app/Http/Controllers/Api/DisplayVersionApiController.php
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Display;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class DisplayVersionApiController extends Controller
|
||||
{
|
||||
public function config(Display $display): JsonResponse
|
||||
{
|
||||
if (! $display->is_active) {
|
||||
return response()->json(['error' => 'Display not configured'], 404);
|
||||
}
|
||||
|
||||
$display->load('versions');
|
||||
|
||||
if ($display->versions->isEmpty()) {
|
||||
return response()->json(['error' => 'Display not configured'], 404);
|
||||
}
|
||||
|
||||
$playlist = [];
|
||||
|
||||
foreach ($display->versions as $version) {
|
||||
$items = $version->activeItems()->get();
|
||||
|
||||
$entry = match ($version->type->value) {
|
||||
'video-display' => $this->videoDisplayData($version, $items),
|
||||
'b2in' => $this->b2inData($version, $items),
|
||||
'offers' => $this->offersData($version, $items),
|
||||
default => null,
|
||||
};
|
||||
|
||||
if ($entry) {
|
||||
$playlist[] = $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'playlist' => $playlist,
|
||||
'updated_at' => $display->versions->max('updated_at')?->toIso8601String(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function check(Display $display): JsonResponse
|
||||
{
|
||||
if (! $display->is_active) {
|
||||
return response()->json(['error' => 'Display not configured'], 404);
|
||||
}
|
||||
|
||||
$display->load('versions');
|
||||
|
||||
if ($display->versions->isEmpty()) {
|
||||
return response()->json(['error' => 'Display not configured'], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'updated_at' => $display->versions->max('updated_at')?->toIso8601String(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function videoDisplayData($version, $items): array
|
||||
{
|
||||
$videos = $items->where('item_type', 'video')->values()->map(fn ($item) => [
|
||||
'src' => 'assets/'.($item->content['filename'] ?? ''),
|
||||
'position' => $item->content['position'] ?? 25,
|
||||
]);
|
||||
|
||||
$footerContent = $items->where('item_type', 'footer')->values()->map(function ($item) {
|
||||
$data = [
|
||||
'headline' => $item->content['headline'] ?? '',
|
||||
'subline' => $item->content['subline'] ?? '',
|
||||
];
|
||||
|
||||
if (! empty($item->content['url'])) {
|
||||
$data['url'] = $item->content['url'];
|
||||
}
|
||||
|
||||
return $data;
|
||||
});
|
||||
|
||||
return [
|
||||
'type' => 'video-display',
|
||||
'version_name' => $version->name,
|
||||
'videoPlaylist' => $videos,
|
||||
'footerContent' => $footerContent,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function b2inData($version, $items): array
|
||||
{
|
||||
$mediaItems = $items->where('item_type', 'media')->values()->map(fn ($item) => [
|
||||
'id' => $item->id,
|
||||
'category' => $item->content['category'] ?? 'immobilien',
|
||||
'media_type' => $item->content['media_type'] ?? 'image',
|
||||
'media_url' => $item->content['media_url'] ?? '',
|
||||
'headline' => $item->content['headline'] ?? '',
|
||||
'subline' => $item->content['subline'] ?? '',
|
||||
'duration_seconds' => $item->content['duration_seconds'] ?? 10,
|
||||
'sort_order' => $item->sort_order,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
return [
|
||||
'type' => 'b2in',
|
||||
'version_name' => $version->name,
|
||||
'settings' => $version->settings ?? [],
|
||||
'items' => $mediaItems,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function offersData($version, $items): array
|
||||
{
|
||||
$slides = $items->where('item_type', 'slide')->values()->map(fn ($item) => [
|
||||
'type' => $item->content['type'] ?? 'product-hero',
|
||||
'duration' => $item->content['duration'] ?? 8000,
|
||||
'image_url' => $item->content['image_url'] ?? '',
|
||||
'badge_text' => $item->content['badge_text'] ?? '',
|
||||
'eyebrow' => $item->content['eyebrow'] ?? '',
|
||||
'title' => $item->content['title'] ?? '',
|
||||
'subline' => $item->content['subline'] ?? '',
|
||||
'price' => $item->content['price'] ?? '',
|
||||
'original_price' => $item->content['original_price'] ?? '',
|
||||
'tag_text' => $item->content['tag_text'] ?? '',
|
||||
'bullets' => $item->content['bullets'] ?? [],
|
||||
'disclaimer' => $item->content['disclaimer'] ?? '',
|
||||
'qr_url' => $item->content['qr_url'] ?? '',
|
||||
'qr_title' => $item->content['qr_title'] ?? '',
|
||||
'contact' => $item->content['contact'] ?? '',
|
||||
'show_brand_text' => $item->content['show_brand_text'] ?? false,
|
||||
'brand_tagline' => $item->content['brand_tagline'] ?? '',
|
||||
]);
|
||||
|
||||
return [
|
||||
'type' => 'offers',
|
||||
'version_name' => $version->name,
|
||||
'settings' => $version->settings ?? [],
|
||||
'slides' => $slides,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
@ -37,8 +37,14 @@ class BasicAuthMiddleware
|
|||
return $next($request);
|
||||
}
|
||||
|
||||
// Skip Basic Auth für Display-API und Short-Links (öffentlicher Zugriff für Display-Seite)
|
||||
if ($request->is('api/display/*') || $request->is('_cabinet/*')) {
|
||||
// Skip Basic Auth für Display-API, Cabinet-Tablet-API und Short-Links (öffentlicher Zugriff für Display-Seiten)
|
||||
// Skip Basic Auth für Display-API, Cabinet-Tablet-API und Short-Links (öffentlicher Zugriff für Display-Seiten)
|
||||
if (
|
||||
$request->is('api/display/*') || $request->is('api/cabinet-tablet/*') || $request->is('_cabinet/*') ||
|
||||
str_contains($request->url(), 'portal.b2in.test') || str_contains($request->url(), 'portal.b2in.eu') ||
|
||||
str_contains($request->url(), 'b2in.test') || str_contains($request->url(), 'b2in.eu')
|
||||
|
||||
) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
|
|
|||
21
app/Http/Middleware/SetLocale.php
Normal file
21
app/Http/Middleware/SetLocale.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SetLocale
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$locale = session('locale');
|
||||
|
||||
if ($locale && in_array($locale, ['de', 'en'])) {
|
||||
app()->setLocale($locale);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue