2022-09-01 09:48:29 +00:00
|
|
|
<?php
|
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
namespace App\Models;
|
2022-09-01 09:48:29 +00:00
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
2022-09-01 09:48:29 +00:00
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
2022-11-06 11:28:22 +00:00
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
|
|
|
use function auth;
|
2022-09-01 09:48:29 +00:00
|
|
|
|
|
|
|
class Balance extends Model
|
|
|
|
{
|
2022-11-06 11:28:22 +00:00
|
|
|
use HasFactory, Cachable;
|
2022-09-01 09:48:29 +00:00
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'order_id',
|
|
|
|
'payment',
|
|
|
|
'amount',
|
|
|
|
'user_id',
|
|
|
|
'paid_at',
|
|
|
|
'trade_id'
|
|
|
|
];
|
|
|
|
|
|
|
|
// route key
|
2022-11-06 11:28:22 +00:00
|
|
|
public function getRouteKeyName(): string
|
2022-09-01 09:48:29 +00:00
|
|
|
{
|
|
|
|
return 'order_id';
|
|
|
|
}
|
|
|
|
|
2022-11-06 11:28:22 +00:00
|
|
|
public function user(): BelongsToAlias
|
2022-09-01 09:48:29 +00:00
|
|
|
{
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
}
|
2022-09-01 13:15:13 +00:00
|
|
|
|
|
|
|
public function scopeThisUser($query)
|
|
|
|
{
|
|
|
|
return $query->where('user_id', auth()->id());
|
|
|
|
}
|
2022-09-01 09:48:29 +00:00
|
|
|
}
|