<?php
namespace PortalPeople\oauth2\controllers;

use Yii;
use yii\web\Controller;

use PortalPeople\oauth2\models\{OauthScope, OauthScopesSearch};

use yii\db\{JsonExpression, Expression, query};
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;

use OAuth2\Server;
use OAuth2\Storage\Pdo;
use OAuth2\GrantType\ClientCredentials;
use OAuth2\GrantType\AuthorizationCode;

/**
 * ScopesController implements the CRUD actions for Oauth2 Scopes.
 */
class ScopesController extends Controller
{

    public $layout = '@PortalPeople/oauth2/views/layouts/main';
    public function actionCreate(){

        $model = new OauthScope();
        if ($model->load(Yii::$app->request->post()) && $model->save()){
            return $this->redirect(['view', 'scope' => $model->scope]);
        }
        return $this->render('create', ['model' => $model]);
    }

        public function actionIndex(){
            $searchModel = new OauthScopesSearch();
            $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
            return $this->render('index', [
                'searchModel' => $searchModel,
                'dataProvider' => $dataProvider,
            ]);
        }
}