/
var
/
www
/
vhosts
/
nabawater
/
common
/
models
/
/var/www/vhosts/nabawater/common/models
mkdir
upload
Name
Size
Mode
Actions
base/
-
0755
rm
ActivityLog.php
175
0644
edit
dl
rm
AddressType.php
1715
0644
edit
dl
rm
AddressTypeLang.php
322
0644
edit
dl
rm
AdminUser.php
8600
0644
edit
dl
rm
Ads.php
2430
0644
edit
dl
rm
AdsLang.php
158
0644
edit
dl
rm
Area.php
1168
0644
edit
dl
rm
AreaLang.php
286
0644
edit
dl
rm
Banner.php
1440
0644
edit
dl
rm
BannerLang.php
170
0644
edit
dl
rm
Branch.php
15646
0644
edit
dl
rm
BranchDeliveryArea.php
202
0644
edit
dl
rm
BranchImage.php
328
0644
edit
dl
rm
BranchLang.php
353
0644
edit
dl
rm
BranchReview.php
695
0644
edit
dl
rm
BranchTimeslot.php
22186
0644
edit
dl
rm
Cart.php
146
0644
edit
dl
rm
Category.php
1597
0644
edit
dl
rm
CategoryLang.php
348
0644
edit
dl
rm
City.php
1167
0644
edit
dl
rm
CityLang.php
286
0644
edit
dl
rm
Cms.php
1396
0644
edit
dl
rm
CmsLang.php
410
0644
edit
dl
rm
Configuration.php
2688
0644
edit
dl
rm
ContactUs.php
508
0644
edit
dl
rm
Country.php
1188
0644
edit
dl
rm
CountryLang.php
301
0644
edit
dl
rm
Coupon.php
851
0644
edit
dl
rm
CouponLang.php
381
0644
edit
dl
rm
CouponUser.php
170
0644
edit
dl
rm
CouponVendor.php
178
0644
edit
dl
rm
CreditHistory.php
204
0644
edit
dl
rm
Cuisine.php
1248
0644
edit
dl
rm
CuisineLang.php
341
0644
edit
dl
rm
DeliveryArea.php
646
0644
edit
dl
rm
Deliveryboy.php
1361
0644
edit
dl
rm
DeliveryboyLang.php
321
0644
edit
dl
rm
DeliveryboyRequest.php
269
0644
edit
dl
rm
DeliveryboyRequestHistory.php
230
0644
edit
dl
rm
DeliveryChargeSetting.php
1040
0644
edit
dl
rm
EmailQueue.php
675
0644
edit
dl
rm
Enquiry.php
158
0644
edit
dl
rm
Faq.php
1306
0644
edit
dl
rm
FaqLang.php
291
0644
edit
dl
rm
Ingredient.php
1226
0644
edit
dl
rm
IngredientLang.php
337
0644
edit
dl
rm
Item.php
1977
0644
edit
dl
rm
ItemBottleRefundHistory.php
2305
0644
edit
dl
rm
ItemImage.php
296
0644
edit
dl
rm
ItemImportTrack.php
190
0644
edit
dl
rm
ItemIngredientGroup.php
1379
0644
edit
dl
rm
ItemIngredientGroupLang.php
379
0644
edit
dl
rm
ItemIngredientGroupMapping.php
238
0644
edit
dl
rm
ItemIngredientMapping.php
215
0644
edit
dl
rm
ItemLang.php
444
0644
edit
dl
rm
ItemMapping.php
575
0644
edit
dl
rm
ItemMappingGroup.php
272
0644
edit
dl
rm
ItemType.php
1269
0644
edit
dl
rm
ItemTypeDetails.php
190
0644
edit
dl
rm
ItemTypeLang.php
329
0644
edit
dl
rm
item_ingredient_group_mapping.php
246
0644
edit
dl
rm
Item_mapping.php
178
0644
edit
dl
rm
Language.php
1440
0644
edit
dl
rm
LoaylityPoint.php
598
0644
edit
dl
rm
LoginForm.php
1857
0644
edit
dl
rm
LoyalityPoint.php
599
0644
edit
dl
rm
LoyalityPointReference.php
218
0644
edit
dl
rm
MallProduct.php
1341
0644
edit
dl
rm
MallProductLang.php
190
0644
edit
dl
rm
Message.php
158
0644
edit
dl
rm
MetaTag.php
526
0644
edit
dl
rm
MobileTranslation.php
198
0644
edit
dl
rm
Newsletter.php
570
0644
edit
dl
rm
NewsletterSubscriber.php
597
0644
edit
dl
rm
NodeOrder.php
166
0644
edit
dl
rm
Notification.php
1505
0644
edit
dl
rm
Order.php
28635
0644
edit
dl
rm
OrderCoupon.php
898
0644
edit
dl
rm
OrderCouponLang.php
190
0644
edit
dl
rm
OrderItem.php
915
0644
edit
dl
rm
OrderItemImage.php
186
0644
edit
dl
rm
OrderItemIngredientGroup.php
901
0644
edit
dl
rm
OrderItemIngredientGroupLang.php
242
0644
edit
dl
rm
OrderItemIngredientMapping.php
234
0644
edit
dl
rm
OrderItemIngredientMappingLang.php
250
0644
edit
dl
rm
OrderItemLang.php
182
0644
edit
dl
rm
OrderMallProduct.php
1436
0644
edit
dl
rm
OrderMallProductLang.php
210
0644
edit
dl
rm
OrderParcel.php
3805
0644
edit
dl
rm
OrderParcelItemImage.php
210
0644
edit
dl
rm
OrderPromotion.php
1608
0644
edit
dl
rm
OrderPromotionLang.php
202
0644
edit
dl
rm
OrderSubscription.php
665
0644
edit
dl
rm
OrderSubscriptionItem.php
214
0644
edit
dl
rm
OrderTax.php
162
0644
edit
dl
rm
OrderTaxLang.php
178
0644
edit
dl
rm
OtpTemp.php
268
0644
edit
dl
rm
ParcelItemType.php
973
0644
edit
dl
rm
ParcelItemTypeLang.php
202
0644
edit
dl
rm
PointHistory.php
178
0644
edit
dl
rm
Post.php
496
0644
edit
dl
rm
PostImage.php
166
0644
edit
dl
rm
Promotion.php
1570
0644
edit
dl
rm
PromotionLang.php
182
0644
edit
dl
rm
Role.php
546
0644
edit
dl
rm
SourceMessage.php
182
0644
edit
dl
rm
SubscriptionLog.php
1380
0644
edit
dl
rm
Tax.php
1142
0644
edit
dl
rm
TaxLang.php
158
0644
edit
dl
rm
TimeZone.php
162
0644
edit
dl
rm
TodaySpecial.php
1508
0644
edit
dl
rm
TodaySpecialLang.php
194
0644
edit
dl
rm
Topup.php
533
0644
edit
dl
rm
TopupHistory.php
682
0644
edit
dl
rm
Unit.php
1934
0644
edit
dl
rm
UnitLang.php
298
0644
edit
dl
rm
User.php
9570
0644
edit
dl
rm
UserAddress.php
2167
0644
edit
dl
rm
UserAddressLang.php
190
0644
edit
dl
rm
UserEmptyBottleRefundRequest.php
242
0644
edit
dl
rm
UserFavourite.php
306
0644
edit
dl
rm
UserFriendList.php
186
0644
edit
dl
rm
UserLevel.php
565
0644
edit
dl
rm
UserNotification.php
194
0644
edit
dl
rm
UserPromotion.php
3075
0644
edit
dl
rm
UserPromotionBranch.php
206
0644
edit
dl
rm
UserPromotionLang.php
388
0644
edit
dl
rm
UserPromotionUser.php
198
0644
edit
dl
rm
UserReminder.php
620
0644
edit
dl
rm
Vendor.php
9928
0644
edit
dl
rm
VendorBank.php
549
0644
edit
dl
rm
VendorCategory.php
186
0644
edit
dl
rm
VendorCuisine.php
182
0644
edit
dl
rm
VendorLang.php
386
0644
edit
dl
rm
VendorType.php
1327
0644
edit
dl
rm
VendorTypeDetail.php
194
0644
edit
dl
rm
VendorTypeLang.php
343
0644
edit
dl
rm
WalletTransaction.php
3564
0644
edit
dl
rm
Edit:
/var/www/vhosts/nabawater/common/models/User.php
(9570B)
<?php namespace common\models; use api\helpers\Jwt; use common\components\AttributeKeyGeneratorBehaviour; use common\components\UserIdentity; use common\helpers\JwtHelper; use common\models\base\BaseUser; use common\models\base\BaseUserAddress; use Yii; use yii\web\IdentityInterface; /** * Class User * @package common\models */ class User extends BaseUser implements IdentityInterface { public $user_address, $order_type, $isDeliveryAvailable; const REGISTRATION_TYPE_NORMAL = 1; const REGISTRATION_TYPE_FACEBOOK = 2; const REGISTRATION_TYPE_GOOGLE_PLUS = 3; const REGISTRATION_TYPE_TWITTER = 4; const NORMAL = 1; const FACEBOOK = 2; const USER_TYPE_SUPER_ADMIN = 1; const USER_TYPE_ADMIN = 1; const USER_TYPE_STAFF = 2; const STATUS_DELETED = 0; const STATUS_ACTIVE = 1; const STATUS_INACTIVE = 2; const AVAILABILITY_STATUS_OFFLINE = 1; const DEVICE_TYPE_ANDROID = 1; const DEVICE_TYPE_IOS = 2; /** * @return array */ public function behaviors() { $behaviors = parent::behaviors(); $behaviors[] = [ 'class' => AttributeKeyGeneratorBehaviour::className(), 'attributes' => ['user_key'] ]; return $behaviors; } /** * Finds an identity by the given ID. * @param string|int $id the ID to be looked for * @return IdentityInterface the identity object that matches the given ID. * Null should be returned if such an identity cannot be found * or the identity is not in an active state (disabled, deleted, etc.) */ public static function findIdentity($id) { return static::findOne(['user_id' => $id, 'status' => self::ACTIVE]); } /** * Finds an identity by the given token. * @param mixed $token the token to be looked for * @param mixed $type the type of the token. The value of this parameter depends on the implementation. * For example, [[\yii\filters\auth\HttpBearerAuth]] will set this parameter to be `yii\filters\auth\HttpBearerAuth`. * @return IdentityInterface the identity object that matches the given token. * @throws \OutOfBoundsException * @throws \BadMethodCallException * Null should be returned if such an identity cannot be found * or the identity is not in an active state (disabled, deleted, etc.) */ public static function findIdentityByAccessToken($token, $type = null) { $userKey = null; $jwtHelper = JwtHelper::getInstance(); if ($jwtHelper->isValid($token)) { $userKey = $jwtHelper->getPrivateClaim($token); } return self::findOne(['user_key' => $userKey]); } /** * @param $username * @return array|null|\yii\db\ActiveRecord */ public static function findByUsername($username) { return static::find() ->where([ 'OR', ['mobile_number' => $username], ['email' => $username] ]) ->andWhere([ 'OR', ['status' => 2], ['status' => 1] ]) ->limit(1) ->one(); } /** * Finds user by password reset token * * @param string $token password reset token * @return static|null */ public static function findByPasswordResetToken($token) { if (!static::isPasswordResetTokenValid($token)) { return null; } return static::findOne([ 'password_reset_token' => $token, 'status' => self::STATUS_ACTIVE, ]); } /** * @param $authId * @return $this */ public static function findByAuthId($authId) { return self::find() ->where(['fb_token' => $authId])->one(); } /** * Finds out if password reset token is valid * * @param string $token password reset token * @return bool */ public static function isPasswordResetTokenValid($token) { if (empty($token)) { return false; } $timestamp = (int) substr($token, strrpos($token, '_') + 1); $expire = Yii::$app->params['user.passwordResetTokenExpire']; return $timestamp + $expire >= time(); } /** * Returns an ID that can uniquely identify a user identity. * @return string|int an ID that uniquely identifies a user identity. */ public function getId() { return $this->getPrimaryKey(); } /** * Returns a key that can be used to check the validity of a given identity ID. * * The key should be unique for each individual user, and should be persistent * so that it can be used to check the validity of the user identity. * * The space of such keys should be big enough to defeat potential identity attacks. * * This is required if [[User::enableAutoLogin]] is enabled. * @return string a key that is used to check the validity of a given identity ID. * @see validateAuthKey() */ public function getAuthKey() { return $this->auth_key; } /** * Validates the given auth key. * * This is required if [[User::enableAutoLogin]] is enabled. * @param string $authKey the given auth key * @return bool whether the given auth key is valid. * @see getAuthKey() */ public function validateAuthKey($authKey) { return $this->getAuthKey() === $authKey; } /** * Validates password * * @param string $password password to validate * @return bool if password provided is valid for current user * @throws \yii\base\InvalidParamException */ public function validatePassword($password) { return Yii::$app->security->validatePassword($password, $this->password_hash); } /** * Generates password hash from password and sets it to the model * * @param string $password * @throws \yii\base\Exception */ public function setPassword($password) { $this->password_hash = Yii::$app->security->generatePasswordHash($password); } /** * Generates "remember me" authentication key * @throws \BadMethodCallException */ public function generateAuthKey() { $this->auth_key = JwtHelper::getInstance()->token($this->user_key); } /** * Generates new password reset token * @throws \yii\base\Exception */ public function generatePasswordResetToken() { $this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time(); } /** * Removes password reset token */ public function removePasswordResetToken() { $this->password_reset_token = null; } /** * @param $event * @throws \Throwable */ protected static function afterLogin($event) { /* @var $model self */ $model = $event->identity; $model->last_login = date('Y-m-d H:i:s'); $model->save(); UserIdentity::getInstance()->init($model->getPrimaryKey()); } /** * @return \yii\db\ActiveQuery */ public function getOrders() { return $this->hasMany(Order::className(), ['user_id' => 'user_id']); } /** * @return \yii\db\ActiveQuery */ public function getUserAddresses() { return $this->hasMany(UserAddress::className(), ['user_id' => 'user_id']); } /** * @return \yii\db\ActiveQuery */ public function getUserCoupons() { return $this->hasMany(UserCoupon::className(), ['user_id' => 'user_id']); } /** * @return UserAddress */ public function getUserAddress() { return $this->user_address === null ? new UserAddress() : $this->user_address; } /** * @param BaseUserAddress $user_address */ public function setUserAddress(BaseUserAddress $user_address) { $this->user_address = $user_address; $this->isDeliveryAvailable = false; } /** * @return mixed */ public function getOrderType() { return $this->order_type; } /** * @param mixed $order_type */ public function setOrderType($order_type) { $this->order_type = $order_type; } /** * @return bool */ public function hasValidOrderOption() { if ($this->order_type === null) { return false; } if ( $this->order_type === Order::ORDER_TYPE_DELIVERY && ( $this->user_address === null || $this->isDeliveryAvailable === false ) ) { return false; } return true; } /** * @param bool $isDeliveryAvailable */ public function setIsDeliveryAvailable($isDeliveryAvailable) { $this->isDeliveryAvailable = $isDeliveryAvailable; } public function getaddress($id) { $query = UserAddress::find()->alias('UA') ->select('UA.*') ->leftJoin(['U' => User::tableName()], 'UA.user_id = U.user_id') ->where([ 'UA.address_status' => UserAddress::ACTIVE, 'U.user_id' => $id ]) ->orderBy(['U']) ->orderBy(['user_address_id' => SORT_DESC]); UserAddress::selectTranslation($query); return $query->asArray()->all(); } }
Save
cmd:
run