<?php
 namespace App\Support; use App\Models\Client; use App\Models\SmsTemplate; class ClientNotificationPolicy { public function smsTemplateDeliverable(string $smsTemplateName): bool { return SmsTemplate::where('name', $smsTemplateName) ->where('status', 'active') ->whereHas('contents', fn ($q) => $q->whereNotNull('content')->where('content', '!=', '')) ->exists(); } public function allowsSmsChannel(Client $client, string $category): bool { if ($category === 'marketing') { return false; } if (empty($client->phone)) { return false; } if (! $client->sms_notifications) { return false; } if (! in_array($client->preferred_contact_method, ['sms', 'both'], true)) { return false; } if ($category === 'exempt') { return true; } if ($category === 'invoice' && ! $client->invoice_reminders) { return false; } if ($category === 'service' && ! $client->service_notifications) { return false; } return true; } } 