Add database migrations and Eloquent models to support user wallets, transaction history, and discount code functionality. Includes a one-to-one relationship between User and Wallet.
23 lines
555 B
PHP
23 lines
555 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use App\Models\Wallet;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
|
|
|
class WalletTransaction extends Model
|
|
{
|
|
protected $fillable = ['wallet_id', 'amount', 'type', 'description', 'transactionable_type', 'transactionable_id'];
|
|
|
|
public function wallet(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Wallet::class);
|
|
}
|
|
|
|
public function transactionable(): MorphTo
|
|
{
|
|
return $this->morphTo();
|
|
}
|
|
} |