php - yii2 creating custom action in controller Page not Found -
namespace app\controllers; use yii; use app\models\projects; use app\models\projectsearch; use app\models\employees; use yii\web\controller; use yii\web\notfoundhttpexception; use yii\filters\verbfilter; /** * projectcontroller implements crud actions projects model. */ class projectcontroller extends controller { public function behaviors() { return [ 'verbs' => [ 'class' => verbfilter::classname(), 'actions' => [ 'delete' => ['post'], ], ], ]; } public function actiongetavailableemployees($id=null){ $available_employees = projects::getavailableemployees($id); return json_encode($available_employees); } }
my /config/web.php
this:
'urlmanager'=>array( 'enableprettyurl'=>'true', 'showscriptname'=>false, 'rules'=>array( '' => '/', '<action:(index|page|contact|login|logout|notallowed)>'=>'site/<action>', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ), ),
when try access url http://mysite.dev/project/get-available-employees/1
getting page not found error, seems problem here? new yii2.
thanks!
Comments
Post a Comment