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-12-27 16:24:41 +00:00
|
|
|
use Eloquent;
|
|
|
|
use GeneaLabs\LaravelModelCaching\CachedBuilder;
|
2022-11-06 11:28:22 +00:00
|
|
|
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo as BelongsToAlias;
|
2022-12-27 16:24:41 +00:00
|
|
|
use Illuminate\Support\Carbon;
|
2022-11-06 11:28:22 +00:00
|
|
|
use function auth;
|
2022-09-01 09:48:29 +00:00
|
|
|
|
2022-11-20 03:40:20 +00:00
|
|
|
/**
|
|
|
|
* App\Models\Balance
|
|
|
|
*
|
2022-12-28 13:19:40 +00:00
|
|
|
* @property int $id
|
|
|
|
* @property string|null $order_id
|
|
|
|
* @property string|null $trade_id
|
|
|
|
* @property string|null $payment
|
|
|
|
* @property string $amount
|
|
|
|
* @property string $remaining_amount
|
|
|
|
* @property string|null $paid_at
|
|
|
|
* @property int|null $user_id
|
|
|
|
* @property Carbon|null $created_at
|
|
|
|
* @property Carbon|null $updated_at
|
|
|
|
* @property-read User|null $user
|
2022-12-27 16:24:41 +00:00
|
|
|
* @method static CachedBuilder|Balance all($columns = [])
|
|
|
|
* @method static CachedBuilder|Balance avg($column)
|
|
|
|
* @method static CachedBuilder|Balance cache(array $tags = [])
|
|
|
|
* @method static CachedBuilder|Balance cachedValue(array $arguments, string $cacheKey)
|
|
|
|
* @method static CachedBuilder|Balance count($columns = '*')
|
|
|
|
* @method static CachedBuilder|Balance disableCache()
|
|
|
|
* @method static CachedBuilder|Balance disableModelCaching()
|
|
|
|
* @method static CachedBuilder|Balance exists()
|
|
|
|
* @method static CachedBuilder|Balance flushCache(array $tags = [])
|
2022-11-20 12:32:49 +00:00
|
|
|
* @method static \GeneaLabs\LaravelModelCaching\CachedBuilder|Balance
|
|
|
|
* getModelCacheCooldown(\Illuminate\Database\Eloquent\Model $instance)
|
2022-12-27 16:24:41 +00:00
|
|
|
* @method static CachedBuilder|Balance inRandomOrder($seed = '')
|
|
|
|
* @method static CachedBuilder|Balance insert(array $values)
|
|
|
|
* @method static CachedBuilder|Balance isCachable()
|
|
|
|
* @method static CachedBuilder|Balance max($column)
|
|
|
|
* @method static CachedBuilder|Balance min($column)
|
|
|
|
* @method static CachedBuilder|Balance newModelQuery()
|
|
|
|
* @method static CachedBuilder|Balance newQuery()
|
|
|
|
* @method static CachedBuilder|Balance query()
|
|
|
|
* @method static CachedBuilder|Balance sum($column)
|
|
|
|
* @method static CachedBuilder|Balance thisUser()
|
|
|
|
* @method static CachedBuilder|Balance truncate()
|
|
|
|
* @method static CachedBuilder|Balance whereAmount($value)
|
|
|
|
* @method static CachedBuilder|Balance whereCreatedAt($value)
|
|
|
|
* @method static CachedBuilder|Balance whereId($value)
|
|
|
|
* @method static CachedBuilder|Balance whereOrderId($value)
|
|
|
|
* @method static CachedBuilder|Balance wherePaidAt($value)
|
|
|
|
* @method static CachedBuilder|Balance wherePayment($value)
|
|
|
|
* @method static CachedBuilder|Balance whereRemainingAmount($value)
|
|
|
|
* @method static CachedBuilder|Balance whereTradeId($value)
|
|
|
|
* @method static CachedBuilder|Balance whereUpdatedAt($value)
|
|
|
|
* @method static CachedBuilder|Balance whereUserId($value)
|
|
|
|
* @method static CachedBuilder|Balance withCacheCooldownSeconds(?int $seconds = null)
|
|
|
|
* @mixin Eloquent
|
2022-11-20 03:40:20 +00:00
|
|
|
*/
|
2022-09-01 09:48:29 +00:00
|
|
|
class Balance extends Model
|
|
|
|
{
|
2022-12-27 16:24:41 +00:00
|
|
|
use Cachable;
|
2022-09-01 09:48:29 +00:00
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
'order_id',
|
|
|
|
'payment',
|
|
|
|
'amount',
|
|
|
|
'user_id',
|
|
|
|
'paid_at',
|
|
|
|
'trade_id'
|
|
|
|
];
|
|
|
|
|
2022-12-27 16:24:41 +00:00
|
|
|
protected $casts = [
|
|
|
|
'paid_at' => 'datetime',
|
|
|
|
'amount' => 'decimal:2',
|
|
|
|
];
|
|
|
|
|
2022-09-01 09:48:29 +00:00
|
|
|
// 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
|
|
|
}
|