<?php

namespace humhub\modules\cgyshare\controllers;

use humhub\modules\admin\components\Controller;
use humhub\modules\cgyshare\models\ConfigureForm;
use Yii;

class AdminController extends Controller
{
    public function actionIndex()
    {
        $model = new ConfigureForm();
        $model->loadSettings();

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $model->saveSettings();
            $this->view->saved();
            return $this->redirect(['/cgy-share/admin']);
        }

        return $this->render('index', [
            'model' => $model,
            'spaceOptions' => $model->getSpaceOptions(),
        ]);
    }
}
