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 the CRUD actions for 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);
}
}
我的/config/web.php
就是这样:
'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>',
),
),
当我尝试使用此http://mysite.dev/project/get-available-employees/1
访问该网址时,我收到了一个找不到网页的错误,这里的问题似乎是什么?我是Yii2的新手。
谢谢!