Hello,
I’m new with YII, and i’m trying to learn things by doing it.
i have setup user acces to my test site, this is working.
Now i wan’t to extend it, with user managment, to dispaly all the users and that kind off stuff.
later on i will add roles so only a admin can acces user managment.
jus to get know how things work.
for now, i have a table users in a datatbase, created backendusercontroller en models.
with crud i created the views that are in the directory views/backendusers/
but when i try to acces the index page in this directory i get a 404 error and don’t know where or how to start solving this.
this is how i try to acces them
http://localhost/index.php?r=backendusers/index
and this is my backendusercontroller
<?php
namespace app\controllers;
use Yii;
use app\models\backenduser;
use app\models\BackenduserSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* BackenduserController implements the CRUD actions for backenduser model.
*/
class BackenduserController extends Controller
{
/**
* {@inheritdoc}
*/
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
/**
* Lists all backenduser models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new BackenduserSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single backenduser model.
* @param string $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new backenduser model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new backenduser();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing backenduser model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param string $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing backenduser model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param string $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the backenduser model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param string $id
* @return backenduser the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = backenduser::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}