la_bot_back/kernel/app_modules/card/models/CardTransaction.php

63 lines
1.6 KiB
PHP
Raw Normal View History

2025-01-20 00:12:30 +03:00
<?php
namespace kernel\app_modules\card\models;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer $from
* @property integer $to
2025-01-26 14:42:47 +03:00
* @property integer $from_balance
* @property integer $to_balance
2025-01-20 00:12:30 +03:00
* @property integer $amount
* @property integer $type
* @property integer $status
*/
class CardTransaction extends Model
{
const DISABLE_STATUS = 0;
const SUCCESS_STATUS = 1;
const IN_PROGRESS_STATUS = 2;
protected $table = 'card_transaction';
2025-01-26 14:42:47 +03:00
protected $fillable = ['from', 'from_balance', 'to', 'to_balance', 'amount', 'type', 'status'];
2025-01-20 00:12:30 +03:00
public static function labels(): array
{
// Заполнить массив
// Пример: [
// 'label' => 'Заголовок',
// 'entity' => 'Сущность',
// 'slug' => 'Slug',
// 'status' => 'Статус',
// ]
return [
'from' => 'От',
'to' => 'Кому',
'amount' => 'Количество',
'type' => 'Тип операции',
'status' => 'Статус',
];
}
2025-01-27 20:03:58 +03:00
public function fromCard(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Card::class, ownerKey: "from");
}
2025-01-20 00:12:30 +03:00
/**
* @return string[]
*/
public static function getStatus(): array
{
return [
self::DISABLE_STATUS => "Не активный",
self::SUCCESS_STATUS => "Завершен",
self::IN_PROGRESS_STATUS => "В процессе",
];
}
}