brands_grid.blade.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. {{--
  2. Blade-шаблон блока «Сетка марок».
  3. $data:
  4. label — надпись над заголовком
  5. heading — заголовок секции
  6. makes — массив строк с названиями марок (выбранных в админке из справочника)
  7. Логотипы берутся из public/images/marks/{slug}.png (статика).
  8. Slug генерируется через Str::slug($make) — «Land Rover» → land-rover.
  9. Если файл не найден — показывается первая буква марки.
  10. --}}
  11. @php
  12. $makes = $data['makes'] ?? [];
  13. sort($makes);
  14. @endphp
  15. @if (!empty($makes))
  16. <section class="brands-section">
  17. <div class="container">
  18. @if (($data['label'] ?? '') || ($data['heading'] ?? ''))
  19. <div style="margin-bottom:clamp(20px,4vw,44px)">
  20. @if ($data['label'] ?? '')
  21. <div class="brands-label">{{ $data['label'] }}</div>
  22. @endif
  23. @if ($data['heading'] ?? '')
  24. <h2 style="color:#fff;margin:0">{{ $data['heading'] }}</h2>
  25. @endif
  26. </div>
  27. @endif
  28. <div class="brands-grid">
  29. @foreach ($makes as $make)
  30. @php
  31. $slug = \Illuminate\Support\Str::slug($make);
  32. $logoPath = 'images/marks/' . $slug . '.png';
  33. $hasLogo = file_exists(public_path($logoPath));
  34. @endphp
  35. <a href="{{ route('catalog', ['make' => $make]) }}" class="brand-tile">
  36. <div class="brand-logo">
  37. @if ($hasLogo)
  38. <img src="{{ asset($logoPath) }}"
  39. alt="{{ $make }}"
  40. class="brand-logo-img">
  41. @else
  42. <span class="brand-logo-letter">{{ mb_strtoupper(mb_substr($make, 0, 1)) }}</span>
  43. @endif
  44. </div>
  45. <div class="brand-name">{{ $make }}</div>
  46. </a>
  47. @endforeach
  48. </div>
  49. </div>
  50. </section>
  51. @endif