63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
||
|
||
namespace kernel\app_modules\card\models;
|
||
|
||
use Illuminate\Database\Eloquent\Model;
|
||
|
||
/**
|
||
* @property integer $from
|
||
* @property integer $to
|
||
* @property integer $from_balance
|
||
* @property integer $to_balance
|
||
* @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';
|
||
|
||
protected $fillable = ['from', 'from_balance', 'to', 'to_balance', 'amount', 'type', 'status'];
|
||
|
||
public static function labels(): array
|
||
{
|
||
// Заполнить массив
|
||
// Пример: [
|
||
// 'label' => 'Заголовок',
|
||
// 'entity' => 'Сущность',
|
||
// 'slug' => 'Slug',
|
||
// 'status' => 'Статус',
|
||
// ]
|
||
|
||
return [
|
||
'from' => 'От',
|
||
'to' => 'Кому',
|
||
'amount' => 'Количество',
|
||
'type' => 'Тип операции',
|
||
'status' => 'Статус',
|
||
];
|
||
}
|
||
|
||
public function fromCard(): \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||
{
|
||
return $this->belongsTo(Card::class, ownerKey: "from");
|
||
}
|
||
|
||
/**
|
||
* @return string[]
|
||
*/
|
||
public static function getStatus(): array
|
||
{
|
||
return [
|
||
self::DISABLE_STATUS => "Не активный",
|
||
self::SUCCESS_STATUS => "Завершен",
|
||
self::IN_PROGRESS_STATUS => "В процессе",
|
||
];
|
||
}
|
||
|
||
} |