@extends('layouts/layoutMaster') @section('title', __('locale.Banners')) @section('page-style') @endsection @section('page-script') @endsection @section('content')
@php use Carbon\Carbon; use Illuminate\Support\Str; use App\Models\Store; use App\Models\Product; use App\Models\Category; $start = $banner?->start_date ? Carbon::parse($banner->start_date) : null; $end = $banner?->end_date ? Carbon::parse($banner->end_date) : null; // Date logic $dateLabel = 'No Expiry Date'; $dateColor = 'secondary'; if ($start && $end) { $now = Carbon::now(); if ($now->between($start, $end)) { $dateLabel = 'Active'; $dateColor = 'success'; } elseif ($now->lt($start)) { $dateLabel = 'Upcoming'; $dateColor = 'warning'; } else { $dateLabel = 'Expired'; $dateColor = 'danger'; } } // Link type color & icon $linkMap = [ 'external_link' => ['color' => 'info', 'icon' => 'link', 'label' => 'External Link'], 'product' => ['color' => 'primary', 'icon' => 'box', 'label' => 'Product'], 'store' => ['color' => 'success', 'icon' => 'building-store', 'label' => 'Store'], 'category' => ['color' => 'warning', 'icon' => 'layout-board', 'label' => 'Category'], ]; $linkMeta = $linkMap[$banner?->link] ?? ['color' => 'secondary', 'icon' => 'question-circle', 'label' => 'N/A']; // Status $statusMeta = $banner?->status == 1 ? ['color' => 'success', 'text' => 'Enabled', 'icon' => 'circle-check'] : ['color' => 'warning', 'text' => 'Disabled', 'icon' => 'xbox-x']; // Linked name $linkedName = match ($banner?->link) { 'store' => Store::find($banner->record_id)?->store_name ?? '-', 'product' => Product::find($banner->record_id)?->title ?? '-', 'category' => Category::find($banner->record_id)?->name ?? '-', 'external_link' => $banner->link_url ?? '-', default => '-', }; @endphp
{{-- Header --}}
{{ $banner?->name ?? '' }}
{{ $dateLabel }}
{{-- Date Range --}} @if ($start && $end) {{ __('locale.Date') }}:
{{ $start->format('d M Y') }} → {{ $end->format('d M Y') }}
@endif {{-- Description --}} @if ($banner?->description) {{ __('locale.Description') }}:
{{ $banner->description }}
@endif {{-- Link Type & Status --}}
{{ $linkMeta['label'] }} {{-- Linked Target --}} @if ($linkedName !== '-')
@if ($banner?->link === 'external_link') {{ Str::limit($linkedName, 40) }} @else {{ $linkedName }} @endif
@endif
{{ $statusMeta['text'] }}
@endsection