in Education by
I have created new controller in the project with gii but I am getting Not Found (#404) error when I try to access it.please help me why i get this error? here is the controller: <?php namespace backend\controllers\phone; use Yii; use common\models\phone\UssdCode; use backend\models\phone\UssdCodeSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; /** * UssdCodeController implements the CRUD actions for UssdCode model. */ class UssdCodeController extends Controller { public function getViewPath() { // return \Yii::getAlias('@backend/views/phone/ussdcode'); } /** * {@inheritdoc} */ public function behaviors() { return [ 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['POST'], ], ], ]; } /** * Lists all UssdCode models. * @return mixed */ public function actionIndex() { $searchModel = new UssdCodeSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); } /** * Displays a single UssdCode model. * @param integer $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 UssdCode model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new UssdCode(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->UssdCodeId]); } return $this->render('create', [ 'model' => $model, ]); } /** * Updates an existing UssdCode model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $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->UssdCodeId]); } return $this->render('update', [ 'model' => $model, ]); } /** * Deletes an existing UssdCode model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $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 UssdCode model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UssdCode the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UssdCode::findOne($id)) !== null) { return $model; } throw new NotFoundHttpException('The requested page does not exist.'); } } and here is the model: <?php namespace common\models\phone; use Yii; /** * This is the model class for table "tbl_ussd_code". * * @property int $UssdCodeId * @property int $CategoryIdRef * @property int $SubCategoryIdRef * @property string $CodeDescription * @property string $UssdCode * @property int $Status */ class UssdCode extends \yii\db\ActiveRecord { /** * {@inheritdoc} */ public static function tableName() { return 'tbl_ussd_code'; } /** * {@inheritdoc} */ public function rules() { return [ [['CategoryIdRef', 'SubCategoryIdRef', 'CodeDescription', 'UssdCode'], 'required'], [['CategoryIdRef', 'SubCategoryIdRef', 'Status'], 'integer'], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'UssdCodeId' => 'Ussd Code ID', ]; } } and here is the index: <?php use yii\helpers\Html; use yii\grid\GridView; /* @var $this yii\web\View */ /* @var $searchModel \backend\models\phone\UssdCodeSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Ussd Codes'; $this->params['breadcrumbs'][] = $this->title; ?>

<?= Html::encode($this->title) ?>

<?= Html::a('Create Ussd Code', ['create'], ['class' => 'btn btn-success']) ?>

<?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?= GridView::widget([ 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'UssdCodeId', 'CategoryIdRef', 'SubCategoryIdRef', 'CodeDescription', 'UssdCode', //'Status', ['class' => 'yii\grid\ActionColumn'], ], ]); ?>
Access url is: http://localhost/test/backend/ussdcode/index why I get Not Found (#404)?? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
You have to be careful with the naming of the controllers and .... For example: ussdcode becomes app\controllers\UssdcodeController; ussd-code becomes app\controllers\UssdCodeController; *This means that the view folder is named as ussd-code and the URl address is called as ussd-code. Controller Class Naming Controller class names can be derived from controller IDs according to the following procedure: Turn the first letter in each word separated by hyphens into upper case. Note that if the controller ID contains slashes, this rule only applies to the part after the last slash in the ID. Remove hyphens and replace any forward slashes with backward slashes. Append the suffix Controller. Prepend the controller namespace.

Related questions

0 votes
    I'm trying to build my app on a physical device. Each time I try to build I get the following ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    This one has been bugging me for a while now. Is there a way I can stop Intellj IDEA from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I tried to follow this tutorial. This is what I did in the console: pip3 install --user --upgrade awscli after ... 's the problem here? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    I tried this: pip3 install --user --upgrade awscli pip3 --version I'm getting: pip 9.0.1 from /downloads/ ... not found. Please help. Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    You need to ensure that Azure DNS can resolve names for your registered domain. What should you implement? A. An MX Record B. A Secondary Zone C. A CNAME Record D. Zone Delegation...
asked Nov 20, 2022 in Education by JackTerrance
0 votes
    Known exploits have a confirmation of and measures can be taken against it to resolve them. (a) True (b) False ... Security questions and answers pdf, mcq on Cyber Security pdf,...
asked Nov 4, 2021 in Education by JackTerrance
0 votes
    The transaction can no longer continue with its normal execution because of some internal condition, such ... topic in chapter Recovery System of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    How is India trying to resolve its differences with China? Please answer the above question....
asked Aug 4, 2022 in Education by JackTerrance
0 votes
    As asked in this question, I also want to know how to resolve a conflicting git stash pop without ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I recently moved my website to a shared hosting solution at asmallorange.com, but I had to set my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I recently moved my website to a shared hosting solution at asmallorange.com, but I had to set my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    I recently moved my website to a shared hosting solution at asmallorange.com, but I had to set my ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 20, 2022 in Education by JackTerrance
0 votes
    How to resolve merge conflicts in Git repository?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    What is a conflict in Git and how to resolve it?...
asked Nov 4, 2020 in Technology by JackTerrance
0 votes
    How to resolve a conflict in Git?...
asked Nov 2, 2020 in Technology by JackTerrance
...