Files
UNIT3D/app/Models/BonTransactions.php

113 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* App\Models\BonTransactions.
*
* @property int $id
* @property int $bon_exchange_id
* @property string $name
* @property string $cost
* @property int|null $sender_id
* @property int|null $receiver_id
* @property int|null $torrent_id
* @property int|null $post_id
* @property string $comment
* @property string $created_at
*/
class BonTransactions extends Model
{
/** @use HasFactory<\Database\Factories\BonTransactionsFactory> */
use HasFactory;
/**
* Indicates If The Model Should Be Timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The Storage Format Of The Model's Date Columns.
*
* @var string
*/
protected $dateFormat = 'U';
/**
* The attributes that aren't mass assignable.
*
* @var string[]
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Get the attributes that should be cast.
*
* @return array{cost: 'decimal:2'}
*/
protected function casts(): array
{
return [
'cost' => 'decimal:2',
];
}
/**
* Belongs To A Sender.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function sender(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class)->withDefault([
'username' => 'System',
'id' => User::SYSTEM_USER_ID,
]);
}
/**
* Belongs To A Receiver.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
*/
public function receiver(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(User::class)->withDefault([
'username' => 'System',
'id' => User::SYSTEM_USER_ID,
]);
}
/**
* Belongs To BonExchange.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo<BonExchange, $this>
*/
public function exchange(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(BonExchange::class)->withDefault([
'value' => 0,
'cost' => 0,
]);
}
}