Add Partner management to replace the hardcoded homepage brand strip
The "Partner" logo row on the homepage was a hard-coded array of ten audio brand names in Home.jsx, not editable through the dashboard. Adds a partners table (name, optional logo, sort order), a PartnerController CRUD under the existing content.manage permission (same one already used for FAQ-style homepage content), and an admin page modeled on Brands.jsx. Home.jsx now fetches /partners and shows each entry's logo if set, falling back to the name as text otherwise. Schema migration now supports one-time seed data (Schema::SEED_DATA, applied by SchemaController::runMigration() only at the moment a table is first created, never again afterwards) so that clicking "Datenbankstruktur aktualisieren" on an existing site populates the new partners table with the previous ten names instead of leaving the homepage strip empty. Verified locally: first migration run creates + seeds the table, a second run neither re-seeds nor errors. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
48a2b5f7a6
commit
040a00a0d7
16 changed files with 413 additions and 67 deletions
|
|
@ -31,6 +31,7 @@ import GalleryPhotos from './pages/admin/GalleryPhotos.jsx';
|
||||||
import Packages from './pages/admin/Packages.jsx';
|
import Packages from './pages/admin/Packages.jsx';
|
||||||
import Services from './pages/admin/Services.jsx';
|
import Services from './pages/admin/Services.jsx';
|
||||||
import Faqs from './pages/admin/Faqs.jsx';
|
import Faqs from './pages/admin/Faqs.jsx';
|
||||||
|
import Partners from './pages/admin/Partners.jsx';
|
||||||
import HomeSections from './pages/admin/HomeSections.jsx';
|
import HomeSections from './pages/admin/HomeSections.jsx';
|
||||||
import PackageProducts from './pages/admin/PackageProducts.jsx';
|
import PackageProducts from './pages/admin/PackageProducts.jsx';
|
||||||
import PackageUpgrades from './pages/admin/PackageUpgrades.jsx';
|
import PackageUpgrades from './pages/admin/PackageUpgrades.jsx';
|
||||||
|
|
@ -88,6 +89,7 @@ export default function App() {
|
||||||
<Route path="packages/:packageId/upgrades" element={<RequirePermission permission="packages.manage"><PackageUpgrades /></RequirePermission>} />
|
<Route path="packages/:packageId/upgrades" element={<RequirePermission permission="packages.manage"><PackageUpgrades /></RequirePermission>} />
|
||||||
<Route path="services" element={<RequirePermission permission="services.manage"><Services /></RequirePermission>} />
|
<Route path="services" element={<RequirePermission permission="services.manage"><Services /></RequirePermission>} />
|
||||||
<Route path="faqs" element={<RequirePermission permission="content.manage"><Faqs /></RequirePermission>} />
|
<Route path="faqs" element={<RequirePermission permission="content.manage"><Faqs /></RequirePermission>} />
|
||||||
|
<Route path="partners" element={<RequirePermission permission="content.manage"><Partners /></RequirePermission>} />
|
||||||
<Route path="home-sections" element={<RequirePermission permission="content.manage"><HomeSections /></RequirePermission>} />
|
<Route path="home-sections" element={<RequirePermission permission="content.manage"><HomeSections /></RequirePermission>} />
|
||||||
<Route path="contact-requests" element={<RequirePermission permission="contact.manage"><ContactRequests /></RequirePermission>} />
|
<Route path="contact-requests" element={<RequirePermission permission="contact.manage"><ContactRequests /></RequirePermission>} />
|
||||||
<Route path="users" element={<RequirePermission permission="users.manage"><AdminUsers /></RequirePermission>} />
|
<Route path="users" element={<RequirePermission permission="users.manage"><AdminUsers /></RequirePermission>} />
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ export default function AdminLayout() {
|
||||||
{ to: '/admin/home-sections', label: 'Startseite', icon: 'home', permission: 'content.manage' },
|
{ to: '/admin/home-sections', label: 'Startseite', icon: 'home', permission: 'content.manage' },
|
||||||
{ to: '/admin/services', label: 'Leistungen', icon: 'briefcase', permission: 'services.manage' },
|
{ to: '/admin/services', label: 'Leistungen', icon: 'briefcase', permission: 'services.manage' },
|
||||||
{ to: '/admin/faqs', label: 'FAQ', icon: 'help', permission: 'content.manage' },
|
{ to: '/admin/faqs', label: 'FAQ', icon: 'help', permission: 'content.manage' },
|
||||||
|
{ to: '/admin/partners', label: 'Partner', icon: 'tag', permission: 'content.manage' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
135
hifi-src/src/pages/admin/Partners.jsx
Normal file
135
hifi-src/src/pages/admin/Partners.jsx
Normal file
|
|
@ -0,0 +1,135 @@
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { api } from '../../api/client.js';
|
||||||
|
import ImageUploadField from '../../components/ImageUploadField.jsx';
|
||||||
|
|
||||||
|
const emptyForm = { name: '', logo_path: '', sort_order: 0 };
|
||||||
|
|
||||||
|
export default function Partners() {
|
||||||
|
const [partners, setPartners] = useState([]);
|
||||||
|
const [form, setForm] = useState(emptyForm);
|
||||||
|
const [editingId, setEditingId] = useState(null);
|
||||||
|
const [error, setError] = useState('');
|
||||||
|
|
||||||
|
const load = () => api.get('/partners').then(setPartners);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const startEdit = (partner) => {
|
||||||
|
setEditingId(partner.id);
|
||||||
|
setForm({ name: partner.name, logo_path: partner.logo_path || '', sort_order: partner.sort_order });
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
setEditingId(null);
|
||||||
|
setForm(emptyForm);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setError('');
|
||||||
|
try {
|
||||||
|
if (editingId) {
|
||||||
|
await api.put(`/partners/${editingId}`, form);
|
||||||
|
} else {
|
||||||
|
await api.post('/partners', form);
|
||||||
|
}
|
||||||
|
resetForm();
|
||||||
|
load();
|
||||||
|
} catch (err) {
|
||||||
|
setError(err.message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDelete = async (id) => {
|
||||||
|
if (!confirm('Partner wirklich löschen?')) return;
|
||||||
|
await api.delete(`/partners/${id}`);
|
||||||
|
load();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid gap-6 lg:grid-cols-3">
|
||||||
|
<div className="lg:col-span-2">
|
||||||
|
<h1 className="mb-4 text-xl font-bold text-neutral-900 dark:text-white">Partner</h1>
|
||||||
|
<p className="mb-4 text-sm text-neutral-500 dark:text-neutral-400">
|
||||||
|
Die Marken-Logozeile auf der Startseite. Ohne Logo wird der Name als Text angezeigt.
|
||||||
|
</p>
|
||||||
|
<div className="overflow-hidden rounded-xl border border-neutral-200 dark:border-neutral-800">
|
||||||
|
<table className="w-full text-left text-sm">
|
||||||
|
<thead className="bg-neutral-50 text-neutral-500 dark:bg-neutral-900 dark:text-neutral-400">
|
||||||
|
<tr>
|
||||||
|
<th className="px-4 py-2">Logo</th>
|
||||||
|
<th className="px-4 py-2">Name</th>
|
||||||
|
<th className="px-4 py-2">Sortierung</th>
|
||||||
|
<th className="px-4 py-2 text-right">Aktionen</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="divide-y divide-neutral-100 dark:divide-neutral-800">
|
||||||
|
{partners.map((partner) => (
|
||||||
|
<tr key={partner.id} className="bg-white dark:bg-neutral-950">
|
||||||
|
<td className="px-4 py-2">
|
||||||
|
{partner.logo_path ? (
|
||||||
|
<img src={partner.logo_path} alt="" className="h-10 w-10 rounded-md object-contain" />
|
||||||
|
) : (
|
||||||
|
<span className="flex h-10 w-10 items-center justify-center rounded-md bg-neutral-100 text-xs text-neutral-400 dark:bg-neutral-800">–</span>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td className="px-4 py-2 font-medium text-neutral-800 dark:text-neutral-100">{partner.name}</td>
|
||||||
|
<td className="px-4 py-2">{partner.sort_order}</td>
|
||||||
|
<td className="px-4 py-2 text-right">
|
||||||
|
<button onClick={() => startEdit(partner)} className="mr-3 text-brand-600 hover:underline">Bearbeiten</button>
|
||||||
|
<button onClick={() => handleDelete(partner.id)} className="text-red-600 hover:underline">Löschen</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
{partners.length === 0 && (
|
||||||
|
<tr><td colSpan={4} className="px-4 py-6 text-center text-neutral-400">Noch keine Partner angelegt.</td></tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form onSubmit={handleSubmit} className="h-fit space-y-4 rounded-xl border border-neutral-200 bg-white p-5 dark:border-neutral-800 dark:bg-neutral-900">
|
||||||
|
<h2 className="font-bold text-neutral-900 dark:text-white">{editingId ? 'Partner bearbeiten' : 'Neuer Partner'}</h2>
|
||||||
|
<div>
|
||||||
|
<label className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300">Name *</label>
|
||||||
|
<input
|
||||||
|
required
|
||||||
|
value={form.name}
|
||||||
|
onChange={(e) => setForm({ ...form, name: e.target.value })}
|
||||||
|
className="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<ImageUploadField
|
||||||
|
value={form.logo_path}
|
||||||
|
onChange={(path) => setForm({ ...form, logo_path: path })}
|
||||||
|
label="Logo (optional)"
|
||||||
|
/>
|
||||||
|
<div>
|
||||||
|
<label className="mb-1 block text-sm font-medium text-neutral-700 dark:text-neutral-300">Sortierung</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={form.sort_order}
|
||||||
|
onChange={(e) => setForm({ ...form, sort_order: Number(e.target.value) })}
|
||||||
|
className="w-full rounded-md border border-neutral-300 bg-white px-3 py-2 text-sm dark:border-neutral-700 dark:bg-neutral-900"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{error && <p className="text-sm text-red-600">{error}</p>}
|
||||||
|
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<button type="submit" className="rounded-md bg-brand-500 px-4 py-2 text-sm font-semibold text-white hover:bg-brand-600">
|
||||||
|
{editingId ? 'Speichern' : 'Anlegen'}
|
||||||
|
</button>
|
||||||
|
{editingId && (
|
||||||
|
<button type="button" onClick={resetForm} className="rounded-md border border-neutral-300 px-4 py-2 text-sm dark:border-neutral-700">
|
||||||
|
Abbrechen
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -37,6 +37,12 @@ const SECTIONS = [
|
||||||
hint: 'Hero, YouTube-Sektion, Handwerk, Beratung, Einblicke, "Mehr als Car-Hifi"',
|
hint: 'Hero, YouTube-Sektion, Handwerk, Beratung, Einblicke, "Mehr als Car-Hifi"',
|
||||||
tables: ['home_sections'],
|
tables: ['home_sections'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'partners',
|
||||||
|
label: 'Partner',
|
||||||
|
hint: 'Marken-Logozeile auf der Startseite (inkl. Logos)',
|
||||||
|
tables: ['partners'],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'permissions',
|
key: 'permissions',
|
||||||
label: 'Berechtigungsgruppen',
|
label: 'Berechtigungsgruppen',
|
||||||
|
|
@ -59,6 +65,7 @@ const TABLE_LABELS = {
|
||||||
app_settings: 'Einstellungen',
|
app_settings: 'Einstellungen',
|
||||||
legal_pages: 'Rechtstexte',
|
legal_pages: 'Rechtstexte',
|
||||||
home_sections: 'Startseiten-Texte',
|
home_sections: 'Startseiten-Texte',
|
||||||
|
partners: 'Partner',
|
||||||
permission_groups: 'Berechtigungsgruppen',
|
permission_groups: 'Berechtigungsgruppen',
|
||||||
permission_group_permissions: 'Berechtigungsgruppen-Rechte',
|
permission_group_permissions: 'Berechtigungsgruppen-Rechte',
|
||||||
admin_users: 'Benutzerkonten',
|
admin_users: 'Benutzerkonten',
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,6 @@ import galleryRear from '../../assets/photos/gallery-rear.webp';
|
||||||
import heroHighlight from '../../assets/leistungen/hero-highlight.webp';
|
import heroHighlight from '../../assets/leistungen/hero-highlight.webp';
|
||||||
import youtubeVideo from '../../assets/videos/youtube-hintergrund.mp4';
|
import youtubeVideo from '../../assets/videos/youtube-hintergrund.mp4';
|
||||||
|
|
||||||
const brands = ['Ground Zero Audio', 'Audison', 'Hertz', 'Helix', 'Brax', 'Gladen', 'Alpine', 'Pioneer', 'Kenwood', 'JVC'];
|
|
||||||
|
|
||||||
// Tailwinds Build-Zeit-Scanner braucht die vollstaendigen Klassennamen woertlich im
|
// Tailwinds Build-Zeit-Scanner braucht die vollstaendigen Klassennamen woertlich im
|
||||||
// Quellcode - ein dynamisch zusammengesetzter String wie `text-${align}` wuerde nicht
|
// Quellcode - ein dynamisch zusammengesetzter String wie `text-${align}` wuerde nicht
|
||||||
// erkannt und aus dem Production-CSS herausgefiltert. Deshalb feste Lookup-Tabellen statt
|
// erkannt und aus dem Production-CSS herausgefiltert. Deshalb feste Lookup-Tabellen statt
|
||||||
|
|
@ -76,6 +74,7 @@ export default function Home() {
|
||||||
const gallery = galleryImages.map((img, i) => ({ ...img, alt: galleryAlts[i] }));
|
const gallery = galleryImages.map((img, i) => ({ ...img, alt: galleryAlts[i] }));
|
||||||
const [faqs, setFaqs] = useState([]);
|
const [faqs, setFaqs] = useState([]);
|
||||||
const [homeSections, setHomeSections] = useState({});
|
const [homeSections, setHomeSections] = useState({});
|
||||||
|
const [partners, setPartners] = useState([]);
|
||||||
// Kurzform, um pro Abschnitt Text/Ausrichtung/Button in der jeweils aktiven Sprache zu lesen.
|
// Kurzform, um pro Abschnitt Text/Ausrichtung/Button in der jeweils aktiven Sprache zu lesen.
|
||||||
const section = (slug) => {
|
const section = (slug) => {
|
||||||
const s = homeSections[slug] || EMPTY_SECTION;
|
const s = homeSections[slug] || EMPTY_SECTION;
|
||||||
|
|
@ -95,6 +94,9 @@ export default function Home() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
api.get('/home-sections').then(setHomeSections).catch(() => {});
|
api.get('/home-sections').then(setHomeSections).catch(() => {});
|
||||||
}, []);
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
api.get('/partners').then(setPartners).catch(() => {});
|
||||||
|
}, []);
|
||||||
// Solange noch keine Google-Rezensionen konfiguriert/erfolgreich abgerufen wurden
|
// Solange noch keine Google-Rezensionen konfiguriert/erfolgreich abgerufen wurden
|
||||||
// (googleReviews === null), zeigt die Seite die festen Beispiel-Texte aus den
|
// (googleReviews === null), zeigt die Seite die festen Beispiel-Texte aus den
|
||||||
// Uebersetzungen - danach die echten, im Admin-Bereich zwischengespeicherten Rezensionen.
|
// Uebersetzungen - danach die echten, im Admin-Bereich zwischengespeicherten Rezensionen.
|
||||||
|
|
@ -262,9 +264,13 @@ export default function Home() {
|
||||||
{t('home.brandsHeading')}
|
{t('home.brandsHeading')}
|
||||||
</p>
|
</p>
|
||||||
<div className="flex flex-wrap items-center justify-center gap-x-8 gap-y-3">
|
<div className="flex flex-wrap items-center justify-center gap-x-8 gap-y-3">
|
||||||
{brands.map((brand, i) => (
|
{partners.map((partner, i) => (
|
||||||
<Reveal key={brand} index={i} className="text-lg font-bold text-neutral-400 dark:text-neutral-600">
|
<Reveal key={partner.id} index={i}>
|
||||||
{brand}
|
{partner.logo_path ? (
|
||||||
|
<img src={partner.logo_path} alt={partner.name} className="h-8 max-w-[8rem] object-contain opacity-70 grayscale transition hover:opacity-100 hover:grayscale-0" />
|
||||||
|
) : (
|
||||||
|
<span className="text-lg font-bold text-neutral-400 dark:text-neutral-600">{partner.name}</span>
|
||||||
|
)}
|
||||||
</Reveal>
|
</Reveal>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
32
hifi/api/database/migration_partners.sql
Normal file
32
hifi/api/database/migration_partners.sql
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
USE hifi_shop;
|
||||||
|
|
||||||
|
-- Ersetzt die bisher hart codierte Partner-Markenliste auf der Startseite durch eine
|
||||||
|
-- editierbare Tabelle (Name + optionales Logo + Sortierung). Additiv, nichts wird geloescht.
|
||||||
|
-- Hinweis: Auf der Live-Seite reicht stattdessen ein Klick auf "Datenbankstruktur aktualisieren"
|
||||||
|
-- unter Admin-Panel -> Einstellungen -> Datenbank - das legt die Tabelle inkl. der bisherigen
|
||||||
|
-- zehn Markennamen als Startdaten automatisch an (siehe Schema::SEED_DATA).
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS partners (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
logo_path VARCHAR(255) NULL,
|
||||||
|
sort_order INT NOT NULL DEFAULT 0,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
-- Nur beim allerersten Anlegen befuellen, nicht bei jedem erneuten Ausfuehren dieses Skripts.
|
||||||
|
INSERT INTO partners (name, sort_order)
|
||||||
|
SELECT name, sort_order FROM (
|
||||||
|
SELECT 'Ground Zero Audio' AS name, 0 AS sort_order UNION ALL
|
||||||
|
SELECT 'Audison', 1 UNION ALL
|
||||||
|
SELECT 'Hertz', 2 UNION ALL
|
||||||
|
SELECT 'Helix', 3 UNION ALL
|
||||||
|
SELECT 'Brax', 4 UNION ALL
|
||||||
|
SELECT 'Gladen', 5 UNION ALL
|
||||||
|
SELECT 'Alpine', 6 UNION ALL
|
||||||
|
SELECT 'Pioneer', 7 UNION ALL
|
||||||
|
SELECT 'Kenwood', 8 UNION ALL
|
||||||
|
SELECT 'JVC', 9
|
||||||
|
) AS defaults
|
||||||
|
WHERE NOT EXISTS (SELECT 1 FROM partners);
|
||||||
|
|
@ -132,6 +132,15 @@ CREATE TABLE brands (
|
||||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB;
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
|
CREATE TABLE partners (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
logo_path VARCHAR(255) NULL,
|
||||||
|
sort_order INT NOT NULL DEFAULT 0,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB;
|
||||||
|
|
||||||
CREATE TABLE car_models (
|
CREATE TABLE car_models (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
brand_id INT NOT NULL,
|
brand_id INT NOT NULL,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ use App\Controllers\PermissionGroupController;
|
||||||
use App\Controllers\ProductController;
|
use App\Controllers\ProductController;
|
||||||
use App\Controllers\HomeSectionController;
|
use App\Controllers\HomeSectionController;
|
||||||
use App\Controllers\PageContentController;
|
use App\Controllers\PageContentController;
|
||||||
|
use App\Controllers\PartnerController;
|
||||||
use App\Controllers\SchemaController;
|
use App\Controllers\SchemaController;
|
||||||
use App\Controllers\ServiceController;
|
use App\Controllers\ServiceController;
|
||||||
use App\Controllers\SettingsController;
|
use App\Controllers\SettingsController;
|
||||||
|
|
@ -153,7 +154,7 @@ $router->get('/contact', $perm('contact.manage', fn($p) => ContactController::in
|
||||||
$router->patch('/contact/{id}', $perm('contact.manage', fn($p) => ContactController::updateStatus($p)));
|
$router->patch('/contact/{id}', $perm('contact.manage', fn($p) => ContactController::updateStatus($p)));
|
||||||
$router->delete('/contact/{id}', $perm('contact.delete', fn($p) => ContactController::destroy($p)));
|
$router->delete('/contact/{id}', $perm('contact.delete', fn($p) => ContactController::destroy($p)));
|
||||||
|
|
||||||
$router->post('/uploads', $anyPerm(['brands.manage', 'models.manage', 'services.manage', 'settings.manage', 'gallery.manage'], fn($p) => UploadController::store()));
|
$router->post('/uploads', $anyPerm(['brands.manage', 'models.manage', 'services.manage', 'settings.manage', 'gallery.manage', 'content.manage'], fn($p) => UploadController::store()));
|
||||||
|
|
||||||
$router->get('/services', $maint('services', fn($p) => ServiceController::index()));
|
$router->get('/services', $maint('services', fn($p) => ServiceController::index()));
|
||||||
$router->post('/services', $perm('services.manage', fn($p) => ServiceController::store()));
|
$router->post('/services', $perm('services.manage', fn($p) => ServiceController::store()));
|
||||||
|
|
@ -168,6 +169,11 @@ $router->delete('/faqs/{id}', $perm('content.manage', fn($p) => FaqController::d
|
||||||
$router->get('/home-sections', fn($p) => HomeSectionController::index());
|
$router->get('/home-sections', fn($p) => HomeSectionController::index());
|
||||||
$router->put('/home-sections/{slug}', $perm('content.manage', fn($p) => HomeSectionController::update($p)));
|
$router->put('/home-sections/{slug}', $perm('content.manage', fn($p) => HomeSectionController::update($p)));
|
||||||
|
|
||||||
|
$router->get('/partners', fn($p) => PartnerController::index());
|
||||||
|
$router->post('/partners', $perm('content.manage', fn($p) => PartnerController::store()));
|
||||||
|
$router->put('/partners/{id}', $perm('content.manage', fn($p) => PartnerController::update($p)));
|
||||||
|
$router->delete('/partners/{id}', $perm('content.manage', fn($p) => PartnerController::destroy($p)));
|
||||||
|
|
||||||
// Nur der zuletzt gecachte Stand - kein Live-Aufruf bei Google pro Seitenbesuch
|
// Nur der zuletzt gecachte Stand - kein Live-Aufruf bei Google pro Seitenbesuch
|
||||||
// (Aktualisierung laeuft ausschliesslich ueber refresh_google_reviews.php).
|
// (Aktualisierung laeuft ausschliesslich ueber refresh_google_reviews.php).
|
||||||
$router->get('/google-reviews', fn($p) => GoogleReviewsController::publicReviews());
|
$router->get('/google-reviews', fn($p) => GoogleReviewsController::publicReviews());
|
||||||
|
|
|
||||||
86
hifi/api/src/Controllers/PartnerController.php
Normal file
86
hifi/api/src/Controllers/PartnerController.php
Normal file
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controllers;
|
||||||
|
|
||||||
|
use App\Config\Database;
|
||||||
|
use App\Support\Http;
|
||||||
|
use App\Support\Uploads;
|
||||||
|
|
||||||
|
class PartnerController
|
||||||
|
{
|
||||||
|
public static function index(): void
|
||||||
|
{
|
||||||
|
$stmt = Database::connection()->query(
|
||||||
|
'SELECT id, name, logo_path, sort_order FROM partners ORDER BY sort_order, name'
|
||||||
|
);
|
||||||
|
Http::send($stmt->fetchAll());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function store(): void
|
||||||
|
{
|
||||||
|
$body = Http::jsonBody();
|
||||||
|
$name = trim($body['name'] ?? '');
|
||||||
|
if ($name === '') {
|
||||||
|
Http::error('Name erforderlich', 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
$db = Database::connection();
|
||||||
|
$stmt = $db->prepare(
|
||||||
|
'INSERT INTO partners (name, logo_path, sort_order) VALUES (?, ?, ?)'
|
||||||
|
);
|
||||||
|
$stmt->execute([
|
||||||
|
$name,
|
||||||
|
trim($body['logo_path'] ?? '') ?: null,
|
||||||
|
(int) ($body['sort_order'] ?? 0),
|
||||||
|
]);
|
||||||
|
|
||||||
|
Http::send(['id' => (int) $db->lastInsertId(), 'name' => $name], 201);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function update(array $params): void
|
||||||
|
{
|
||||||
|
$id = (int) $params['id'];
|
||||||
|
$body = Http::jsonBody();
|
||||||
|
$name = trim($body['name'] ?? '');
|
||||||
|
if ($name === '') {
|
||||||
|
Http::error('Name erforderlich', 422);
|
||||||
|
}
|
||||||
|
|
||||||
|
$newLogoPath = trim($body['logo_path'] ?? '') ?: null;
|
||||||
|
$db = Database::connection();
|
||||||
|
$oldStmt = $db->prepare('SELECT logo_path FROM partners WHERE id = ?');
|
||||||
|
$oldStmt->execute([$id]);
|
||||||
|
$oldLogoPath = $oldStmt->fetchColumn();
|
||||||
|
|
||||||
|
$stmt = $db->prepare(
|
||||||
|
'UPDATE partners SET name = ?, logo_path = ?, sort_order = ? WHERE id = ?'
|
||||||
|
);
|
||||||
|
$stmt->execute([
|
||||||
|
$name,
|
||||||
|
$newLogoPath,
|
||||||
|
(int) ($body['sort_order'] ?? 0),
|
||||||
|
$id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
Uploads::deleteIfOrphaned($oldLogoPath ?: null, $newLogoPath);
|
||||||
|
|
||||||
|
Http::send(['ok' => true]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function destroy(array $params): void
|
||||||
|
{
|
||||||
|
$id = (int) $params['id'];
|
||||||
|
$db = Database::connection();
|
||||||
|
|
||||||
|
$oldStmt = $db->prepare('SELECT logo_path FROM partners WHERE id = ?');
|
||||||
|
$oldStmt->execute([$id]);
|
||||||
|
$oldLogoPath = $oldStmt->fetchColumn();
|
||||||
|
|
||||||
|
$stmt = $db->prepare('DELETE FROM partners WHERE id = ?');
|
||||||
|
$stmt->execute([$id]);
|
||||||
|
|
||||||
|
Uploads::deleteIfOrphaned($oldLogoPath ?: null, null);
|
||||||
|
|
||||||
|
Http::send(['ok' => true]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -38,6 +38,7 @@ class SchemaController
|
||||||
try {
|
try {
|
||||||
$db->exec($createSql);
|
$db->exec($createSql);
|
||||||
$actions[] = "Tabelle `$table` angelegt";
|
$actions[] = "Tabelle `$table` angelegt";
|
||||||
|
self::seedTable($db, $table, $actions);
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$actions[] = "FEHLER beim Anlegen von `$table`: " . $e->getMessage();
|
$actions[] = "FEHLER beim Anlegen von `$table`: " . $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
@ -61,6 +62,28 @@ class SchemaController
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string[] $actions
|
||||||
|
*/
|
||||||
|
private static function seedTable(\PDO $db, string $table, array &$actions): void
|
||||||
|
{
|
||||||
|
$rows = Schema::SEED_DATA[$table] ?? [];
|
||||||
|
if ($rows === []) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$columns = array_keys($rows[0]);
|
||||||
|
$placeholders = implode(', ', array_fill(0, count($columns), '?'));
|
||||||
|
$columnList = implode(', ', array_map(fn($c) => "`$c`", $columns));
|
||||||
|
$stmt = $db->prepare("INSERT INTO `$table` ($columnList) VALUES ($placeholders)");
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
$stmt->execute(array_values($row));
|
||||||
|
}
|
||||||
|
|
||||||
|
$actions[] = "Tabelle `$table` mit " . count($rows) . " Standardeinträgen befüllt";
|
||||||
|
}
|
||||||
|
|
||||||
private static function buildReport(): array
|
private static function buildReport(): array
|
||||||
{
|
{
|
||||||
$db = Database::connection();
|
$db = Database::connection();
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class SettingsController
|
||||||
// werden können (fehlende Spalten bekommen einfach ihren DB-Standardwert).
|
// werden können (fehlende Spalten bekommen einfach ihren DB-Standardwert).
|
||||||
private const TABLE_COLUMNS = [
|
private const TABLE_COLUMNS = [
|
||||||
'brands' => ['id', 'name', 'slug', 'image_path', 'sort_order', 'created_at', 'updated_at'],
|
'brands' => ['id', 'name', 'slug', 'image_path', 'sort_order', 'created_at', 'updated_at'],
|
||||||
|
'partners' => ['id', 'name', 'logo_path', 'sort_order', 'created_at', 'updated_at'],
|
||||||
'car_models' => ['id', 'brand_id', 'name', 'slug', 'image_path', 'sort_order', 'created_at', 'updated_at'],
|
'car_models' => ['id', 'brand_id', 'name', 'slug', 'image_path', 'sort_order', 'created_at', 'updated_at'],
|
||||||
'packages' => ['id', 'car_model_id', 'name', 'slug', 'description', 'markup_type', 'markup_value', 'icon_name', 'tagline', 'price_text', 'is_featured', 'sort_order', 'created_at', 'updated_at'],
|
'packages' => ['id', 'car_model_id', 'name', 'slug', 'description', 'markup_type', 'markup_value', 'icon_name', 'tagline', 'price_text', 'is_featured', 'sort_order', 'created_at', 'updated_at'],
|
||||||
'package_products' => ['id', 'package_id', 'source_url', 'name_override', 'scraped_name', 'scraped_price', 'scraped_currency', 'scraped_image_url', 'price_updated_at', 'scrape_status', 'scrape_error', 'sort_order', 'created_at', 'updated_at'],
|
'package_products' => ['id', 'package_id', 'source_url', 'name_override', 'scraped_name', 'scraped_price', 'scraped_currency', 'scraped_image_url', 'price_updated_at', 'scrape_status', 'scrape_error', 'sort_order', 'created_at', 'updated_at'],
|
||||||
|
|
@ -79,6 +80,7 @@ class SettingsController
|
||||||
'permissions' => ['permission_groups', 'permission_group_permissions'],
|
'permissions' => ['permission_groups', 'permission_group_permissions'],
|
||||||
'legal' => ['legal_pages'],
|
'legal' => ['legal_pages'],
|
||||||
'home' => ['home_sections'],
|
'home' => ['home_sections'],
|
||||||
|
'partners' => ['partners'],
|
||||||
];
|
];
|
||||||
|
|
||||||
// Welche Tabellenspalte(n) pro Tabelle einen Bild-Pfad enthalten - dieselbe Zuordnung
|
// Welche Tabellenspalte(n) pro Tabelle einen Bild-Pfad enthalten - dieselbe Zuordnung
|
||||||
|
|
@ -93,6 +95,7 @@ class SettingsController
|
||||||
'gallery_photos' => ['image_path'],
|
'gallery_photos' => ['image_path'],
|
||||||
'brands' => ['image_path'],
|
'brands' => ['image_path'],
|
||||||
'car_models' => ['image_path'],
|
'car_models' => ['image_path'],
|
||||||
|
'partners' => ['logo_path'],
|
||||||
'app_settings' => ['hero_image_path', 'logo_path', 'logo_dark_path'],
|
'app_settings' => ['hero_image_path', 'logo_path', 'logo_dark_path'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -158,6 +158,15 @@ class Schema
|
||||||
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
) ENGINE=InnoDB",
|
) ENGINE=InnoDB",
|
||||||
|
|
||||||
|
'partners' => "CREATE TABLE partners (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
name VARCHAR(100) NOT NULL,
|
||||||
|
logo_path VARCHAR(255) NULL,
|
||||||
|
sort_order INT NOT NULL DEFAULT 0,
|
||||||
|
created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
||||||
|
) ENGINE=InnoDB",
|
||||||
|
|
||||||
'car_models' => "CREATE TABLE car_models (
|
'car_models' => "CREATE TABLE car_models (
|
||||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
brand_id INT NOT NULL,
|
brand_id INT NOT NULL,
|
||||||
|
|
@ -428,6 +437,14 @@ class Schema
|
||||||
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||||
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
|
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
|
||||||
],
|
],
|
||||||
|
'partners' => [
|
||||||
|
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
|
||||||
|
'name' => 'VARCHAR(100) NOT NULL',
|
||||||
|
'logo_path' => 'VARCHAR(255) NULL',
|
||||||
|
'sort_order' => 'INT NOT NULL DEFAULT 0',
|
||||||
|
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||||
|
'updated_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
|
||||||
|
],
|
||||||
'car_models' => [
|
'car_models' => [
|
||||||
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
|
'id' => 'INT AUTO_INCREMENT PRIMARY KEY',
|
||||||
'brand_id' => 'INT NOT NULL',
|
'brand_id' => 'INT NOT NULL',
|
||||||
|
|
@ -548,4 +565,23 @@ class Schema
|
||||||
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
'created_at' => 'DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Einmalige Startdaten fuer eine Tabelle, die von SchemaController::runMigration() direkt
|
||||||
|
// nach dem CREATE TABLE eingefuegt werden - nur in dem Moment, in dem die Tabelle neu
|
||||||
|
// angelegt wird, danach nie wieder (verhindert, dass absichtlich geloeschte Zeilen bei
|
||||||
|
// einem erneuten Klick auf "Datenbankstruktur aktualisieren" wieder auftauchen).
|
||||||
|
public const SEED_DATA = [
|
||||||
|
'partners' => [
|
||||||
|
['name' => 'Ground Zero Audio', 'sort_order' => 0],
|
||||||
|
['name' => 'Audison', 'sort_order' => 1],
|
||||||
|
['name' => 'Hertz', 'sort_order' => 2],
|
||||||
|
['name' => 'Helix', 'sort_order' => 3],
|
||||||
|
['name' => 'Brax', 'sort_order' => 4],
|
||||||
|
['name' => 'Gladen', 'sort_order' => 5],
|
||||||
|
['name' => 'Alpine', 'sort_order' => 6],
|
||||||
|
['name' => 'Pioneer', 'sort_order' => 7],
|
||||||
|
['name' => 'Kenwood', 'sort_order' => 8],
|
||||||
|
['name' => 'JVC', 'sort_order' => 9],
|
||||||
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
hifi/assets/index-BhPW2e0c.css
Normal file
1
hifi/assets/index-BhPW2e0c.css
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -43,9 +43,9 @@
|
||||||
"sameAs": ["https://www.youtube.com/@hifiplanet2812"]
|
"sameAs": ["https://www.youtube.com/@hifiplanet2812"]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script type="module" crossorigin src="/assets/index-CKoRo60o.js"></script>
|
<script type="module" crossorigin src="/assets/index-CEZHSio1.js"></script>
|
||||||
<link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js">
|
<link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js">
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-D_qjU0tn.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-BhPW2e0c.css">
|
||||||
</head>
|
</head>
|
||||||
<body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100">
|
<body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100">
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue