*/ protected $fillable = [ 'unique_id', 'card_state_id', 'card_type_id', 'region', 'branch_id', 'customer_name', 'customer_surname', 'customer_patronic_name', 'born_at', 'old_surname', 'citizenship', 'passport_serie', 'passport_id', 'passport_given_at', 'passport_given_by', 'born_place', 'job_location', 'passport_address', 'real_address', 'phone', 'phone_additional', 'status', 'passport_one', 'passport_two', 'passport_three', 'passport_four', 'paid', 'notes', 'user_id', ]; /** * The attributes that should be cast. * * @var array */ protected $casts = [ 'born_at' => 'date', 'passport_given_at' => 'date', ]; /** * User * * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Card state * * @return BelongsTo */ public function cardState(): BelongsTo { return $this->belongsTo(CardState::class, 'card_state_id'); } /** * Card type * * @return BelongsTo */ public function cardType(): BelongsTo { return $this->belongsTo(CardType::class, 'card_type_id'); } /** * Branch * * @return BelongsTo */ public function branch(): BelongsTo { return $this->belongsTo(Branch::class, 'branch_id'); } /** * "boot" method for model */ protected static function boot() { parent::boot(); static::creating(CardOrderRepo::creating()); } /** * Check if order is paid */ public function isPaid(): bool { return $this->paid; } /** * Price for order */ public function priceAmount(): float { return $this->cardState->price ?? 32; } public function really() { return $this->id; } /** * Panel url */ public function panelUrl(string $type = 'index'): string { return match ($type) { 'index' => sprintf('%s/resources/card-orders', config('nova.path')), default => config('nova.path'), }; } }