bubasuma\simplechat\models\User::getAll PHP Méthode

getAll() public static méthode

public static getAll ( ) : static[]
Résultat static[]
    public static function getAll()
    {
        return static::find()->with('profile')->all();
    }

Usage Example

 public function actionIndex($contactId)
 {
     if (\Yii::$app->request->isPost) {
         $this->setUser(\Yii::$app->request->get('userId'));
         return \Yii::$app->getResponse()->redirect(Url::current(['userId' => null]));
     }
     $user = $this->user;
     if ($contactId == $user->id) {
         throw new ForbiddenHttpException('You cannot open this conversation');
     }
     $contact = User::findIdentity(['id' => $contactId]);
     if (empty($contact)) {
         throw new NotFoundHttpException();
     }
     $this->view->title = $contact->name;
     $conversationDataProvider = call_user_func([$this->modelClass, 'loadConversations'], $user->id, [$this, 'formatConversation'], 8);
     $messageDataProvider = call_user_func([$this->modelClass, 'loadMessages'], $user->id, $contact->id, [$this, 'formatMessage'], 10);
     $users = [];
     foreach (User::getAll() as $userItem) {
         $users[] = ['label' => $userItem->name, 'url' => Url::current(['userId' => $userItem->id]), 'options' => ['class' => in_array($userItem->id, [$user->id, $contact->id]) ? 'disabled' : ''], 'linkOptions' => ['data-method' => 'post']];
     }
     return $this->render('index.twig', compact('conversationDataProvider', 'messageDataProvider', 'users', 'user', 'contact'));
 }
All Usage Examples Of bubasuma\simplechat\models\User::getAll