- Add Enums: TransactionType, TransactionStatus, PaymentGateway - Migrations: wallets, wallet_transactions, wallet_activity_logs - Models: Wallet, WalletTransaction, WalletActivityLog - Services: WalletService with complete business logic - Controllers: WalletController, PaymentController - Filament Resources: WalletResource, WalletTransactionResource - Artisan Command: ifnex:token for API token generation - Sanctum integration with statefulApi and exception handling - Full API endpoints: balance, transactions, admin-adjust, freeze/unfreeze
65 lines
1.4 KiB
PHP
65 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Notifications\Notifiable;
|
|
use Laravel\Sanctum\HasApiTokens; // ← اضافه کنید
|
|
use App\Models\Wallet;
|
|
|
|
class User extends Authenticatable
|
|
{
|
|
use HasApiTokens, HasFactory, Notifiable; // ← HasApiTokens اضافه شد
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'email',
|
|
'password',
|
|
'phone',
|
|
'role',
|
|
'is_active',
|
|
];
|
|
|
|
protected $hidden = [
|
|
'password',
|
|
'remember_token',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'email_verified_at' => 'datetime',
|
|
'password' => 'hashed',
|
|
'is_active' => 'boolean',
|
|
'role' => \App\Enums\UserRole::class,
|
|
];
|
|
}
|
|
|
|
public function isSuperAdmin(): bool
|
|
{
|
|
return $this->role === \App\Enums\UserRole::SuperAdmin;
|
|
}
|
|
|
|
public function isTrackingOperator(): bool
|
|
{
|
|
return $this->role === \App\Enums\UserRole::TrackingOperator;
|
|
}
|
|
|
|
public function isDataEntry(): bool
|
|
{
|
|
return $this->role === \App\Enums\UserRole::DataEntry;
|
|
}
|
|
|
|
public function isCustomer(): bool
|
|
{
|
|
return $this->role === \App\Enums\UserRole::Customer;
|
|
}
|
|
|
|
//کیف پول
|
|
public function wallet()
|
|
{
|
|
return $this->hasOne(Wallet::class);
|
|
}
|
|
}
|