<?php  namespace App\Models;  use App\Enums\DomainLanguages; use Illuminate\Support\Facades\DB; use App\Observers\ApplicantObserver; use App\Traits\HasApplicantMetadata; use App\Enums\InternalBaApplicantType; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany;  /**  * @property ?Location $location  * @property ?Department $department  * @property bool $latest_metadata_exists  */ class Applicant extends Model { 	use HasApplicantMetadata;  	protected $casts = [ 		'filled' => 'boolean', 		'draft' => 'boolean', 		'is_offline' => 'boolean', 		'default_language' => DomainLanguages::class, 		'active' => 'boolean', 		'survey_filling_started' => 'datetime', 		'survey_filling_finished' => 'datetime', 		'has_conflicting_answers' => 'boolean', 		'employee_type' => InternalBaApplicantType::class, 		'has_sufficient_info_for_ba_survey' => 'boolean', 		// 'code' => 'encrypted', // TO DO - CHECK 	];  	protected $attributes = [ 		'notification_sent' => false, 		'reminder_sent' => false, 		'invitation_sent' => false, 		'active' => true, 	];  	public static function generateCode(): string 	{ 		do { 			$pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';  			$random_string = ''; 			$tried_combo = [];  			for ($i = 0; $i < 10; $i++) { 				$picker = rand(0, strlen($pool) - 1); 				$random_string .= substr($pool, $picker, 1); 			}  			if (in_array($random_string, $tried_combo)) { 				continue; 			}  			$tried_combo[] = $random_string; 		} while (DB::table('applicants')->whereRaw('BINARY `code` = ?', [$random_string])->exists());  		return $random_string; 	}  	public static function generateControlNumber(): int 	{ 		return mt_rand(1000000000, 9999999999); 	}  	protected static function initObservers(): string 	{ 		return ApplicantObserver::class; 	}  	public function survey(): BelongsTo{}  	public function answers(): HasMany{}  	public function applicantSurveyQuestionOrder(): HasMany{}  	public function parent(): BelongsTo{}  	public function child(): HasOne{}  	public function profession(): BelongsTo{}  	public function location(): BelongsTo{}  	public function department(): BelongsTo{}  	public function client(): BelongsTo{}  	public function applicantCompanyPivot(): HasMany{}  	public function companies(): BelongsToMany{}  	public function scrambledQuestions(): BelongsToMany{}  	public function getAnswerCodes(): string{}  	public function getFillingDuration(): ?int{}  	public function scopeFillingOnlineSurvey(Builder $query): Builder{}  	public function scopeFillingOfflineSurvey(Builder $query): Builder{}  	public function scopeHasNotCompletedSurvey(Builder $query): Builder{}  	public function scopeHasNotCompletedSurveyOrIsDraft(object $query): Builder{}  	public function scopeMailable(Builder $query): Builder{}  	public function scopeDoesntHaveMail(Builder $query): Builder{}  	public function scopeAvailable(Builder $query): Builder{}  	public function scopeFinal(Builder $query): Builder{}  	public function scopeFilterByAnswers(Builder $query, ?array $filter_values = null): Builder{}  	public function scopeFilterByLocationAndDepartment(Builder $query, ?array $locations_id = null, ?array $departments_id = null): Builder{}  	public function scopeByLanguage(Builder $query, ?DomainLanguages $language = null): Builder{}  	public function scopeSearch(Builder $query, ?string $search = null): Builder{}  	protected function getIncludes(): array{} }