Proje: Okul Platform · Hub: Okul Platform — Domain

CustomerUserService (Bases)

app/Services/Bases/CustomerUserService.php

B2B portalda hangi okulların görülebileceğini, erişim izinlerini yönetir. customerUser() global helper üzerinden aktif kullanıcıya erişir (IdentifyCustomer middleware’den).

Ana Metodlar

$service->getSchoolIds()             // Tüm bağlı okul ID'leri
$service->getContentAccessSchoolIds() // İçerik yönetimi olan okul ID'leri
$service->getLeadAccessSchoolIds()   // Lead görebileceği okul ID'leri
$service->checkContentAccess(int $schoolId) // Bu okul için içerik erişimi var mı?
$service->checkLeadAccess(int $schoolId)    // Bu okul için lead erişimi var mı?
$service->hasPaidSchool()            // Ücretli (is_customer=true) okulu var mı?
$service->getPaidSchoolIds()         // Ücretli okul ID'leri
$service->getAllowedContentSchoolIds(array $ids) // Verilen ID'lerden içerik erişimli olanlar
$service->getAllowedLeadSchoolIds(array $ids)    // Verilen ID'lerden lead erişimli olanlar
$service->getSchoolNamesByIds(array $ids)        // Okul ID → isim mapping

school_name vs name

$schoolName = $schoolFilter->school_name ?? $schoolFilter->name ?? null;

school_name → Model yüklemesinde
name → IdentifyCustomer middleware alias’ı

HasCustomer Policy Trait Bağlantısı

trait HasCustomer
{
    protected function isCustomerWithPaidSchool(User $user, CustomerUserService $service): bool
    // → $user->isAdmin() || ($user->isCustomer() && $service->hasPaidSchool())
 
    protected function isCustomerHasContentAccess(User $user, CustomerUserService $service): bool
    // → count($service->getContentAccessSchoolIds()) > 0
}