Files
tbbank-new/app/Modules/CardOrder/Models/CardOrder.php

124 lines
3.1 KiB
PHP

<?php
namespace App\Modules\CardOrder\Models;
use App\Models\User;
use App\Modules\Branch\Interfaces\BelongsToBranch;
use App\Modules\Branch\Models\Branch;
use App\Modules\LoanOrder\Repositories\LoanOrderRepository;
use App\Modules\OnlinePayment\Contracts\HasOnlinePayments;
use App\Modules\OrderStatus\Interfaces\HasStatus;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* @property int $id
* @property null|string $unique_id
* @property int $card_state_id
* @property int $card_type_id
* @property string $region
* @property int $branch_id
* @property string $customer_name
* @property string $customer_surname
* @property null|string $customer_patronic_name
* @property \Illuminate\Support\Carbon $born_at
* @property null|string $old_surname
* @property string $citizenship
* @property string $passport_serie
* @property string $passport_id
* @property \Illuminate\Support\Carbon $passport_given_at
* @property string $passport_given_by
* @property string $born_place
* @property null|string $job_location
* @property null|string $passport_address
* @property null|string $real_address
* @property null|string $phone
* @property null|string $phone_additional
* @property null|string $status
* @property string $passport_one
* @property string $passport_two
* @property string $passport_three
* @property string $passport_four
* @property null|string $notes
* @property int $user_id
* @property null|\Illuminate\Support\Carbon $created_at
* @property null|\Illuminate\Support\Carbon $updated_at
* @property null|\Illuminate\Support\Carbon $deleted_at
* @property bool $paid
*/
class CardOrder extends Model implements BelongsToBranch, HasStatus
{
use SoftDeletes;
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'born_at' => 'date',
'passport_given_at' => 'date',
'paid' => 'boolean',
];
/**
* User
*
* @return BelongsTo<User, $this>
*/
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
/**
* Card state
*
* @return BelongsTo<CardState, $this>
*/
public function cardState(): BelongsTo
{
return $this->belongsTo(CardState::class, 'card_state_id');
}
/**
* Card type
*
* @return BelongsTo<CardType, $this>
*/
public function cardType(): BelongsTo
{
return $this->belongsTo(CardType::class, 'card_type_id');
}
/**
* Branch
*
* @return BelongsTo<Branch, $this>
*/
public function branch(): BelongsTo
{
return $this->belongsTo(Branch::class, 'branch_id');
}
/**
* "boot" method for model
*/
protected static function boot()
{
parent::boot();
static::creating(LoanOrderRepository::creating());
static::created(LoanOrderRepository::created());
}
/**
* Price for card
*/
public function priceAmount(): int|float|string
{
return $this->cardState->price ?? 32;
}
}