add all controllers logic

This commit is contained in:
root
2026-03-11 17:53:15 -04:00
parent 3e6c577085
commit 2ef71cc92b
421 changed files with 12009 additions and 5211 deletions
@@ -0,0 +1,50 @@
<?php
namespace App\Services\Policy;
use Illuminate\Support\Facades\Log;
class PolicyContentService
{
private const TYPES = [
'school' => 'school_policy.html',
'picture' => 'picture_policy.html',
];
public function getPolicy(string $type): array
{
$type = strtolower(trim($type));
if (!isset(self::TYPES[$type])) {
throw new \InvalidArgumentException('Unsupported policy type.');
}
$filename = self::TYPES[$type];
$path = resource_path('policies/' . $filename);
if (!is_file($path)) {
Log::warning('Policy file missing.', ['type' => $type, 'path' => $path]);
return [
'type' => $type,
'title' => $this->titleFor($type),
'content' => '',
'format' => 'html',
'source' => $path,
'updated_at' => null,
];
}
return [
'type' => $type,
'title' => $this->titleFor($type),
'content' => (string) file_get_contents($path),
'format' => 'html',
'source' => $path,
'updated_at' => date('Y-m-d H:i:s', filemtime($path)),
];
}
private function titleFor(string $type): string
{
return $type === 'picture' ? 'Picture Policy' : 'School Policy';
}
}