PK
œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Notice: ob_end_clean(): Failed to delete buffer. No buffer to delete in /home/qpfajntr/ekhaya.265thami.com/y77.php on line 8
| Dir : /home/qpfajntr/wallet.265thami.com/application__b25eadc/app/ |
| Server: Linux premium288.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64 IP: 162.254.39.137 |
| Dir : /home/qpfajntr/wallet.265thami.com/application__b25eadc/app/User.php |
<?php
namespace App;
use App\Models\Wallet;
use Storage;
use App\Models\Ticketcomment;
use App\Models\Currency;
use Illuminate\Notifications\Notifiable;
use Lab404\Impersonate\Models\Impersonate;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends \TCG\Voyager\Models\User
{
use Notifiable;
use Impersonate;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'customer_id', 'password','avatar', 'whatsapp', 'phonenumber', 'first_name', 'last_name', 'verified','role_id', 'settings', 'merchant', 'currency_id', 'qrcode_id' ,'social', 'account_status', 'verification_token', 'balance', 'json_data', 'is_ticket_admin' , 'identity_verified','wallet_id', 'cs_token','cs_token_added_at'
];
protected $with = ['profile'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function profile(){
return $this->hasOne(\App\Models\Profile::class);
}
public function RecentActivity(){
return $this->hasMany(\App\Models\Transaction::class);
}
public function balance(){
return $this->currentWallet()->amount;
}
public function isAdministrator(){
if ($this->role_id == 1) {
return true;
}
return false;
}
public function currentCurrency(){
if (!is_null($this->currentWallet())) {
return $this->currentWallet()->currency;
}
$currency = Currency::first();
$wallet = $this->newWallet($currency->id);
$this->currency_id = $currency->id;
$this->save();
return $currency;
}
public function walletsCollection(){
return $this->hasMany(\App\Models\Wallet::class);
}
public function wallets(){
$collection = $this->walletsCollection()->with('Currency')->with('TransferMethod')->where('id','!=', $this->wallet_id)->where('transfer_method_id', '!=', null)->get();
foreach ($collection as $key => $value) {
if(is_null($value->currency)){
$collection->forget($key);
}
}
return $collection ;
}
public function currentWallet(){
// check if the user curency_id property is an existing currency id
// if it returns NULL that mean the currency was deleted and the user is using an obsolet currency as a default currency
if(Wallet::where('id', $this->wallet_id)->first() != NULL ){
//check if the user has a wallet on that currency if true return that wallet, else create a new wallet on that currency
$currentWallet = Wallet::with('Currency')->where('id', $this->wallet_id)->first();
if ($currentWallet != NULL) {
return $currentWallet;
} else {
// The currency exists in the database but the user does not have a wallet on that currency.
//Create a new wallet on that currency and return it
}
}
$currency = Currency::orderBy('id','asc')->first();
$wallet = $this->newWallet($currency->id);
$this->currency_id = $currency->id;
$this->save();
return Wallet::with('Currency')->where('id', $this->wallet_id)->where('user_id', $this->id)->first();
}
public function currentWalletBalance(){
return $this->currentWallet()->amount;
}
public function walletByCurrencyId($id){
if (!is_null($this->walletsCollection()->with('Currency')->where('currency_id',$id)->first())) {
return $this->walletsCollection()->with('Currency')->where('currency_id',$id)->first();
}
return $this->newWallet($id);
}
public function newWallet($currency_id){
$wallet = Wallet::where('user_id', $this->id)->where('currency_id', $currency_id)->first();
if (!is_null($wallet)) {
return $wallet;
}
// $currency = Currency::findOrFail($currency_id);
// return Wallet::create([
// 'is_crypto' => $currency->is_crypto,
// 'user_id' => $this->id,
// 'currency_id' => $currency_id,
// 'amount' => 0,
// ]);
}
public function getBalanceAttribute($value){
return $this->currentWalletBalance();
}
public function setBalanceAttribute($value){
$wallet = $this->currentWallet();
$wallet->amount = $value;
$wallet->save();
}
public function comments(){
return $this->hasMany(Comment::class);
}
public function avatar(){
return $this->avatar;
}
public function isActivated(){
return (bool)$this->verified;
}
public function canImpersonate()
{
// For example
return $this->role_id == 1;
}
}