Beispiel #1
0
 public function testRemove()
 {
     $userId = null;
     \Yii::$app->on(User::EVENT_REMOVED, function ($event) use(&$userId) {
         $userId = $event->user->getId();
     });
     $user = User::find()->byId(1)->one();
     $this->assertInstanceOf(User::class, $user);
     $this->assertTrue($user->remove());
     $this->assertEquals($user->getId(), $userId);
     $this->assertNull(User::find()->byId(1)->one());
 }
 public function unlikeStatus($data)
 {
     $user = User::find($data['user_id']);
     if ($user[0]) {
         foreach ($user[0]->like as $like) {
             if ($like['id'] == $data['post_id']) {
                 $user[0]->like()->edge($like)->delete();
             }
         }
     } else {
         foreach ($user->like as $like) {
             if ($like['id'] == $data['post_id']) {
                 $user->like()->edge($like)->delete();
             }
         }
     }
     return 1;
 }
Beispiel #3
0
 /**
  * @param int $id
  * @throws ModelValidateException
  * @throws NotFoundHttpException
  * @throws ForbiddenHttpException
  */
 public function actionDelete($id)
 {
     $user = User::find()->byId($id)->oneOrThrow();
     if ($user->getId() != \Yii::$app->getUser()->getId()) {
         throw new ForbiddenHttpException();
         // todo-rbac
     }
     if ($user->remove()) {
         return;
     } else {
         throw new ModelValidateException($user);
     }
 }
Beispiel #4
0
 public function getAll()
 {
     return UserEntity::find();
 }
Beispiel #5
0
 /**
  * Finds an identity by the given ID.
  *
  * @param string|integer $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 User::find()->byId($id)->one();
 }