Fix Laravel Pint formatting
This commit is contained in:
@@ -51,7 +51,7 @@ class CommunicationFamilyService
|
||||
}
|
||||
|
||||
$names = array_map(static function ($row) {
|
||||
return trim(($row['firstname'] ?? '') . ' ' . ($row['lastname'] ?? ''));
|
||||
return trim(($row['firstname'] ?? '').' '.($row['lastname'] ?? ''));
|
||||
}, $rows);
|
||||
|
||||
return implode(' & ', $names);
|
||||
|
||||
@@ -9,7 +9,7 @@ class CommunicationLogService
|
||||
{
|
||||
public function log(array $payload): void
|
||||
{
|
||||
if (!Schema::hasTable('communication_logs')) {
|
||||
if (! Schema::hasTable('communication_logs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace App\Services\Communication;
|
||||
class CommunicationPreviewService
|
||||
{
|
||||
private CommunicationTemplateService $templates;
|
||||
|
||||
private CommunicationStudentService $students;
|
||||
|
||||
private CommunicationFamilyService $families;
|
||||
|
||||
public function __construct(
|
||||
@@ -26,7 +28,7 @@ class CommunicationPreviewService
|
||||
string $teacherName
|
||||
): array {
|
||||
$template = $this->templates->findTemplateByKey($templateKey);
|
||||
if (!$template) {
|
||||
if (! $template) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
@@ -35,7 +37,7 @@ class CommunicationPreviewService
|
||||
}
|
||||
|
||||
$student = $this->students->getStudentBasic($studentId);
|
||||
if (!$student) {
|
||||
if (! $student) {
|
||||
return [
|
||||
'ok' => false,
|
||||
'status' => 404,
|
||||
@@ -46,7 +48,7 @@ class CommunicationPreviewService
|
||||
$salutation = $this->families->guardianSalutation($familyId);
|
||||
|
||||
$autoVars = [
|
||||
'student_fullname' => trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? '')),
|
||||
'student_fullname' => trim(($student['firstname'] ?? '').' '.($student['lastname'] ?? '')),
|
||||
'student_grade' => $student['grade'] ?? '',
|
||||
'parent_salutation' => $salutation,
|
||||
'date' => $this->formatLocalDate('Y-m-d'),
|
||||
@@ -70,6 +72,7 @@ class CommunicationPreviewService
|
||||
{
|
||||
return (string) preg_replace_callback('/\\{\\{\\s*([a-zA-Z0-9_\\.]+)\\s*\\}\\}/', function ($m) use ($vars) {
|
||||
$key = $m[1];
|
||||
|
||||
return htmlspecialchars((string) ($vars[$key] ?? ''), ENT_QUOTES, 'UTF-8');
|
||||
}, $template);
|
||||
}
|
||||
@@ -79,6 +82,7 @@ class CommunicationPreviewService
|
||||
if (function_exists('local_date') && function_exists('utc_now')) {
|
||||
return (string) local_date(utc_now(), $format);
|
||||
}
|
||||
|
||||
return now()->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ use App\Services\EmailService;
|
||||
class CommunicationSendService
|
||||
{
|
||||
private EmailService $mailer;
|
||||
|
||||
private CommunicationLogService $logService;
|
||||
|
||||
public function __construct(EmailService $mailer, CommunicationLogService $logService)
|
||||
@@ -61,7 +62,7 @@ class CommunicationSendService
|
||||
$sendOk = false;
|
||||
}
|
||||
|
||||
if (!$sendOk && $error === null) {
|
||||
if (! $sendOk && $error === null) {
|
||||
$error = 'Mailer returned false';
|
||||
}
|
||||
|
||||
@@ -90,6 +91,7 @@ class CommunicationSendService
|
||||
private function normalizeEmails(array $values): array
|
||||
{
|
||||
$out = array_values(array_unique(array_filter(array_map('strval', $values))));
|
||||
|
||||
return array_values(array_filter($out, static function ($email) {
|
||||
return $email !== '';
|
||||
}));
|
||||
|
||||
@@ -33,13 +33,13 @@ class CommunicationStudentService
|
||||
->orderBy('sc.id', 'desc')
|
||||
->first();
|
||||
|
||||
if (!$row) {
|
||||
if (! $row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$row = (array) $row;
|
||||
$grade = $row['registration_grade'] ?? '';
|
||||
if (!$grade && !empty($row['class_section_name'])) {
|
||||
if (! $grade && ! empty($row['class_section_name'])) {
|
||||
$grade = $row['class_section_name'];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class CommunicationTemplateService
|
||||
->get()
|
||||
->map(function ($row) use ($keyColumn, $bodyColumn) {
|
||||
$row = (array) $row;
|
||||
|
||||
return [
|
||||
'template_key' => (string) ($row[$keyColumn] ?? ''),
|
||||
'subject' => (string) ($row['subject'] ?? ''),
|
||||
@@ -35,7 +36,7 @@ class CommunicationTemplateService
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
if (!$row) {
|
||||
if (! $row) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ class CommunicationTemplateService
|
||||
{
|
||||
$keyColumn = Schema::hasColumn('email_templates', 'template_key') ? 'template_key' : 'code';
|
||||
$bodyColumn = Schema::hasColumn('email_templates', 'body') ? 'body' : 'body_html';
|
||||
|
||||
return [$keyColumn, $bodyColumn];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user