ApiController.php 675 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace app\controllers;
  3. use Yii;
  4. use yii\filters\AccessControl;
  5. use yii\web\Controller;
  6. use yii\web\Response;
  7. use yii\filters\VerbFilter;
  8. use app\models\LoginForm;
  9. use app\models\ContactForm;
  10. use app\models\Accounts;
  11. class ApiController extends Controller
  12. {
  13. public function actionIndex()
  14. {
  15. $accountsModel = Accounts::find()
  16. ->where(['id' => 1])
  17. ->one();
  18. foreach($accountsModel as $account){
  19. //var_dump($account->name);
  20. }
  21. var_dump($accountsModel->name);
  22. die();
  23. return $this->render('apitest');
  24. }
  25. }