mirror of
https://github.com/janickiy/yii2-nomer
synced 2025-03-09 15:39:59 +00:00
add files to project
This commit is contained in:
commit
5cac498444
3729 changed files with 836998 additions and 0 deletions
44
modules/admin/controllers/AccountsController.php
Normal file
44
modules/admin/controllers/AccountsController.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace app\modules\admin\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use app\models\Telegram;
|
||||
use yii\helpers\Url;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class AccountsController extends AdminController
|
||||
{
|
||||
public function actionTelegram()
|
||||
{
|
||||
$model = new Telegram();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => Telegram::find(),
|
||||
'sort' => ['defaultOrder' => ['id' => SORT_DESC]]
|
||||
]);
|
||||
|
||||
if (Yii::$app->getRequest()->getIsPost()) {
|
||||
$model->load(Yii::$app->getRequest()->post());
|
||||
|
||||
if (!$model->validate()) {
|
||||
return $this->render('telegram', compact('model', 'dataProvider'));
|
||||
}
|
||||
|
||||
$model->save();
|
||||
$this->refresh();
|
||||
}
|
||||
|
||||
return $this->render('telegram', compact('model', 'dataProvider'));
|
||||
}
|
||||
|
||||
public function actionDeleteTelegram($id)
|
||||
{
|
||||
if ($instance = Telegram::findOne($id)) $instance->delete();
|
||||
if (!$instance) throw new NotFoundHttpException('Инстанс не найден.');
|
||||
$referrer = Yii::$app->getRequest()->getReferrer();
|
||||
$url = $referrer ? $referrer : Url::to(['accounts/telegram']);
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue