Hi guys. Used google many times, but cant find the answer. Trying to make defaultAction working.
Have 2 controllers. SiteController (this is main) and TourController. When i trying to call /tour, it makes 404 error. I thought the problem was in my TourController. I pasted $defaultAction in SiteController to check how it works. And it works! So what’s the problem? Help please!
TourController has a variable:
public $defaultAction = 'all';
This is my TourController:
namespace app\controllers;
use Yii;
use yii\web\Controller;
use app\models\Tournament;
class TourController extends Controller {
public $defaultAction = 'all';
public function actionAll()
{
$something = 'Tournament is here';
$array = Tournament::getAll();
return $this->render('all',['somethingView'=>$something, 'arrayView'=>$array]);
}
public function actionSingle($id)
{
$stour = Tournament::getOne($id);
if (!empty($stour)){
return $this->render('single',['stour'=>$stour]);
}
throw new \yii\web\NotFoundHttpException('404');
}
}