3
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('title', (isset($sponsor) ? 'Editar' : 'Nuevo') . ' Sponsor - Admin OnAPB')
|
||||
|
||||
@section('content')
|
||||
<div class="page-header">
|
||||
<h2><i class="bi bi-star-fill text-warning"></i> {{ isset($sponsor) ? 'Editar' : 'Nuevo' }} Sponsor</h2>
|
||||
<a href="{{ route('admin.sponsors.index') }}" class="btn-admin-outline">
|
||||
<i class="bi bi-arrow-left"></i> Volver
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="admin-card">
|
||||
<div class="card-body">
|
||||
<form action="{{ isset($sponsor) ? route('admin.sponsors.update', $sponsor->id_sponsor) : route('admin.sponsors.store') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@if(isset($sponsor))
|
||||
@method('PUT')
|
||||
@endif
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Nombre del Sponsor *</label>
|
||||
<input type="text" name="nombre" class="form-control" value="{{ old('nombre', $sponsor->nombre ?? '') }}" required maxLength="100">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">URL del sitio (opcional)</label>
|
||||
<input type="url" name="url" class="form-control" value="{{ old('url', $sponsor->url ?? '') }}" placeholder="https://example.com">
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Orden de aparición</label>
|
||||
<input type="number" name="orden" class="form-control" value="{{ old('orden', $sponsor->orden ?? 0) }}">
|
||||
<small class="text-muted">Menor número aparece primero.</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 pt-4">
|
||||
<div class="form-check form-switch mt-2">
|
||||
<input class="form-check-input" type="checkbox" name="activo" id="activo" value="1" {{ old('activo', $sponsor->activo ?? true) ? 'checked' : '' }}>
|
||||
<label class="form-check-label" for="activo">Sponsor Activo</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Logo / Imagen *</label>
|
||||
<input type="file" name="imagen" class="form-control" {{ isset($sponsor) ? '' : 'required' }} accept="image/*">
|
||||
<div class="mt-3 text-center border p-3 rounded bg-light" style="min-height: 150px; display: flex; align-items: center; justify-content: center;">
|
||||
@if(isset($sponsor) && $sponsor->imagen)
|
||||
<img src="{{ asset($sponsor->imagen) }}" id="preview" style="max-width: 100%; max-height: 120px; object-fit: contain;">
|
||||
@else
|
||||
<div id="no-preview" class="text-muted">
|
||||
<i class="bi bi-image fs-1 d-block"></i>
|
||||
Vista previa
|
||||
</div>
|
||||
<img src="#" id="preview" style="max-width: 100%; max-height: 120px; object-fit: contain; display: none;">
|
||||
@endif
|
||||
</div>
|
||||
<small class="text-muted d-block mt-2 text-center">Formato recomendado: PNG transparente o fondo blanco.</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div class="d-flex justify-content-end gap-2">
|
||||
<button type="submit" class="btn btn-primary px-4">
|
||||
<i class="bi bi-save"></i> {{ isset($sponsor) ? 'Actualizar' : 'Guardar' }} Sponsor
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
document.querySelector('input[name="imagen"]').addEventListener('change', function(e) {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
const preview = document.getElementById('preview');
|
||||
const noPreview = document.getElementById('no-preview');
|
||||
preview.src = event.target.result;
|
||||
preview.style.display = 'block';
|
||||
if (noPreview) noPreview.style.display = 'none';
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@endsection
|
||||
@@ -0,0 +1,78 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('title', 'Sponsors - Admin OnAPB')
|
||||
|
||||
@section('content')
|
||||
<div class="mb-5 d-flex justify-content-between align-items-end">
|
||||
<div>
|
||||
<span class="text-primary fw-bold text-uppercase tracking-widest d-block mb-2">Alianzas Estratégicas</span>
|
||||
<h1 class="display-4 fw-bold font-header mb-0">Sponsors<span class="text-primary">.</span></h1>
|
||||
</div>
|
||||
<a href="{{ route('admin.sponsors.create') }}" class="btn-admin-primary">
|
||||
<i class="bi bi-plus-lg me-2"></i> NUEVO SPONSOR
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="admin-card">
|
||||
@if($sponsors->isEmpty())
|
||||
<div class="text-center py-5">
|
||||
<i class="bi bi-star text-muted mb-3" style="font-size: 3rem;"></i>
|
||||
<p class="fs-5 text-muted">No hay sponsors registrados.</p>
|
||||
</div>
|
||||
@else
|
||||
<div class="table-responsive">
|
||||
<table class="kinetic-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 80px;">Orden</th>
|
||||
<th>Imagen</th>
|
||||
<th>Nombre</th>
|
||||
<th>Enlace</th>
|
||||
<th>Estado</th>
|
||||
<th class="text-end">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($sponsors as $s)
|
||||
<tr>
|
||||
<td><span class="badge bg-light text-dark fw-bold border p-2">{{ $s->orden }}</span></td>
|
||||
<td>
|
||||
<div class="bg-white p-2 border" style="width: 100px; height: 50px; display: inline-flex; align-items: center; justify-content: center;">
|
||||
<img src="{{ asset($s->imagen) }}" alt="{{ $s->nombre }}" style="max-width: 100%; max-height: 100%; object-fit: contain;">
|
||||
</div>
|
||||
</td>
|
||||
<td><span class="fw-bold fs-5 text-uppercase">{{ $s->nombre }}</span></td>
|
||||
<td>
|
||||
@if($s->url)
|
||||
<a href="{{ $s->url }}" target="_blank" class="small text-muted font-monospace">{{ Str::limit($s->url, 30) }}</a>
|
||||
@else
|
||||
<span class="text-muted small">SIN ENLACE</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>
|
||||
@if($s->activo)
|
||||
<span class="badge bg-success text-white text-uppercase px-2 py-1">ACTIVO</span>
|
||||
@else
|
||||
<span class="badge bg-light text-muted border text-uppercase px-2 py-1">OCULTO</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="text-end">
|
||||
<a href="{{ route('admin.sponsors.edit', $s->id_sponsor) }}" class="btn btn-sm btn-light border me-1">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form action="{{ route('admin.sponsors.destroy', $s->id_sponsor) }}" method="POST" class="d-inline delete-form confirm-submit" data-confirm-text="¿Eliminar este sponsor?">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user