modules/admin/controllers/UserPurchasedSubscriptionsController.php
/**
     * Lists all UserPurchasedSubscriptions models.
     * @return mixed
     */
Lists all UserPurchasedSubscriptions models.
@return mixed
Lists all UserPurchasedSubscriptions models . @return mixed
public function actionIndex()
    {
        $searchModel = new UserPurchasedSubscriptionsSearch();
        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        $users = ArrayHelper::map(User::find()->where(['IN', 'user_type', [User::USER_TYPE_NORMAL]])->all(), 'id', function ($data) {
            return $data['first_name'] . " " . $data['last_name'] . " (" . $data['email'] . ")";
        });
        $totalEarn = 0.00;
        $data = $dataProvider->getModels();
        if (!empty($data)) {
            foreach ($data as $key => $dataRow) {
                if (!empty($dataRow) && $dataRow instanceof UserPurchasedSubscriptions) {
                    $totalEarn += $dataRow->amount;
                }
            }
        }
        return $this->render('index', [
            'searchModel' => $searchModel,
            'dataProvider' => $dataProvider,
            'users' => $users,
            'totalEarn' => $totalEarn
        ]);
    }
public function actionIndex ( ) { $ searchModel = new UserPurchasedSubscriptionsSearch ( ) ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> queryParams ) ; $ users = ArrayHelper :: map ( User :: find ( ) -> where ( [ 'IN' , 'user_type' , [ User :: USER_TYPE_NORMAL ] ] ) -> all ( ) , 'id' , function ( $ data ) { return $ data [ 'first_name' ] . " " . $ data [ 'last_name' ] . "  ( " . $ data [ 'email' ] . " ) " ; } ) ; $ totalEarn = 0.00 ; $ data = $ dataProvider -> getModels ( ) ; if ( ! empty ( $ data ) ) { foreach ( $ data as $ key => $ dataRow ) { if ( ! empty ( $ dataRow ) && $ dataRow instanceof UserPurchasedSubscriptions ) { $ totalEarn += $ dataRow -> amount ; } } } return $ this -> render ( 'index' , [ 'searchModel' => $ searchModel , 'dataProvider' => $ dataProvider , 'users' => $ users , 'totalEarn' => $ totalEarn ] ) ; }
Lists all UserPurchasedSubscriptions models.
Lists all UserPurchasedSubscriptions models .