belongsTo(User::class); } static public function credit($user){ if(is_object($user)){ return self::where('user_id',$user->id)->sum('amount'); }else{ return self::where('user_id',$user)->sum('amount'); } } static public function charge($user,$amount){ if(is_object($user)){ self::create([ 'amount'=>$amount, 'user_id'=>$user->id, 'desc'=>'شارژ کیف پول' ]); return true; }else{ self::create([ 'amount'=>$amount, 'user_id'=>$user, 'desc'=>'شارژ کیف پول' ]); return true; } } }