Proje: Okul Platform · Hub: Okul Platform — Conventions
Custom Business Rules (app/Rules/)
CanNotMoreThanOneListingProduct
Bir okul için birden fazla listing ürünü eklenemez.
// SchoolProductPrice oluştururken
new CanNotMoreThanOneListingProduct($productId)IfHasPaidListingProductItTakeDopingProduct
Ücretli listing ürünü varsa doping ürünü de alınabilir. İş kuralı: Sadece ücretli okullar doping alabilir.
AgeRangeFormat
{min}-{max} format kontrolü. Anaokulu yaş aralığı formatı için:
- Hyphen zorunlu:
3-6 - Validation mesajı:
lang/tr/validation.php
TelFormat
Telefon format kuralı.
DateRange
Tarih aralığı format kuralı.
Admin/ ve Customer/ Klasörleri
Rules/Admin/ ve Rules/Customer/ altında context-specific kurallar.
Laravel ValidationRule Interface
class CanNotMoreThanOneListingProduct implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!$isValid) {
$fail('...');
}
}
}PHP 8.1+ ValidationRule interface’i kullanılıyor (eski Rule::custom yerine).
Related
- api-product-usage-limits — Listing ve doping ürün kuralları
- api-form-request-patterns — FormRequest’lerde kural kullanımı