is_mobile) { return true; } $normalizedNumber = (string) $this->normalized_number; if (preg_match('/^\+33[67]\d{8}$/', $normalizedNumber) === 1) { return true; } $rawDigits = preg_replace('/\D+/', '', (string) $this->raw_number) ?? ''; return preg_match('/^0[67]\d{8}$/', $rawDigits) === 1 || preg_match('/^33[67]\d{8}$/', $rawDigits) === 1 || preg_match('/^0033[67]\d{8}$/', $rawDigits) === 1; } /** * @return BelongsTo */ public function contact(): BelongsTo { return $this->belongsTo(Contact::class); } /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ 'is_valid' => 'boolean', 'is_mobile' => 'boolean', 'is_primary' => 'boolean', ]; } }