| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\controllers;
- use app\models\HelpCategory;
- use app\models\HelpVideo;
- use Yii;
- use app\models\Help;
- use app\models\HealpSearch as HelpSearch;
- use yii\data\ActiveDataProvider;
- use yii\web\Controller;
- use yii\web\NotFoundHttpException;
- use yii\filters\VerbFilter;
- use yii\filters\AccessControl;
- /**
- * HelpController implements the CRUD actions for Help model.
- */
- class DopomogaController extends Controller
- {
- /**
- * @inheritdoc
- */
- public function behaviors()
- {
- return [
- 'verbs' => [
- 'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['POST'],
- ],
- ],
- ];
- }
- /**
- * Lists all Help models.
- * @return mixed
- */
- public function actionIndex()
- {
- $dataProvider = new ActiveDataProvider([
- 'query' => HelpCategory::find(),
- ]);
- return $this->render('index',[
- 'dataProvider' =>$dataProvider,
- ]);
- }
- public function actionCategory($slug)
- {
- $category = HelpCategory::findOne(['slug' => $slug]);
- $videos = HelpVideo::findAll(['cat_id' => $category->id]);
- $title = $category->title;
- $key = $category->key_words;
- $desc = $category->description;
- $this->view->title = $title;
- $this->view->registerMetaTag(['name' => 'keywords', 'content' => $key]);
- $this->view->registerMetaTag(['name' => 'description', 'content' => $desc]);
- $dataProvider = new ActiveDataProvider([
- 'query' => Help::find()->where(['cat_id' => $category->id]),
- 'pagination' => [
- 'defaultPageSize' => 5,
- ],
- 'sort' => [
- 'defaultOrder' => [
- 'id' => SORT_DESC,
- ],
- ],
- ]);
- return $this->render('category',[
- 'dataProvider' => $dataProvider,
- 'videos' => $videos,
- ]);
- }
- public function actionView($slug)
- {
- if (false != ($model = Help::findOne(['slug' => $slug]))) {
- return $this->render('view', [
- 'model' => $model,
- ]);
- } else {
- throw new NotFoundHttpException(Yii::t('app', 'Post not found'));
- }
- }
- }
|