ifnex/04_Laravel/app/Models/Wallet.php
Kazem Alghasi 6aa18f76a8 feat(db): implement wallet and discount code systems
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.
2026-08-05 17:35:58 +03:30

25 lines
524 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\User;
use App\Models\WalletTransaction;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Wallet extends Model
{
protected $fillable = ['user_id', 'balance'];
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function transactions(): HasMany
{
return $this->hasMany(WalletTransaction::class);
}
}