<?php
namespace app\models;
use Yii;
use yii\base\Model;
use yii\db\ActiveRecord;
class News extends ActiveRecord{
public function attributeLabels()
{
return [
'caption' => Yii::t('app', 'Заголовок'),
'full_text' => Yii::t('app', 'Полное описание'),
'img' => Yii::t('app', 'Ссылка на картинку'),
'date' => Yii::t('app', 'Дата в формате UNIX'),
];
}
}
?>
<a href="<?=Url::to(['site/news', 'id' => $post->id])?>"></a>
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'pattern' => '<action>/<id:\d+>/',
'route' => 'site/news',
'suffix' => '.hmls'
],
[
'pattern' => '<action>',
'route' => 'site/<action>',
]
],
],
public function actionLogin()
{
if (!Yii::$app->user->isGuest) {
return $this->goHome();
}
$login_model = new Login();
if(Yii::$app->request->post('Login'))
{
$login_model->attributes = Yii::$app->request->post('Login');
if($login_model->validate()){
Yii::$app->user->login($login_model->getUser());
$this->goHome();
}
}
return $this->render('login', compact('login_model'));
}