48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\LegalDocument;
|
|
use Illuminate\View\View;
|
|
|
|
class LegalController extends Controller
|
|
{
|
|
public function privacy(): View
|
|
{
|
|
return $this->show('privacy');
|
|
}
|
|
|
|
public function cookies(): View
|
|
{
|
|
return $this->show('cookies');
|
|
}
|
|
|
|
public function terms(): View
|
|
{
|
|
return $this->show('terms');
|
|
}
|
|
|
|
private function show(string $type): View
|
|
{
|
|
abort_unless(in_array($type, ['privacy', 'cookies', 'terms'], true), 404);
|
|
|
|
$document = LegalDocument::query()
|
|
->where('type', $type)
|
|
->where('status', 'published')
|
|
->where(fn ($query) => $query->whereNull('published_at')->orWhere('published_at', '<=', now()))
|
|
->latest('published_at')
|
|
->latest('updated_at')
|
|
->first();
|
|
|
|
$fallbacks = [
|
|
'privacy' => ['Privacy Policy', 'BeatBook is designed for UK GDPR compliance, data minimisation, access/export and deletion workflows. A published privacy policy can be maintained from the administration area.'],
|
|
'cookies' => ['Cookie Policy', 'Necessary cookies operate the service. Analytics and marketing cookies require consent. A published cookie policy can be maintained from the administration area.'],
|
|
'terms' => ['Terms of Service', 'Marketplace, DJ, client, cancellation, payment, refund and acceptable-use terms can be maintained from the administration area.'],
|
|
];
|
|
|
|
[$fallbackTitle, $fallbackBody] = $fallbacks[$type];
|
|
|
|
return view('legal.page', compact('document', 'fallbackTitle', 'fallbackBody', 'type'));
|
|
}
|
|
}
|