In my project i have 2 users Organiser
and User
with 2 different tables.
I want to define rules for Event
table for both users. For example if Organiser
is logged in which i can see as Yii::$app->user->isGuest
and if User
is logged in which i can see as Yii::$app->users->isGuest
and i want to define separate rules for both users.
if Organiser
logged in than only he can view that entire section and not user
and same if user
is logged in than he can only create
the list of users.
If any visitor clicks on Create an Event
than they should redirect to Organiser Login
or if they click on Create user
than they should redirect to User Login
.
I have defined the rules like below but when it always redirect to Organiser Login
and not the user login
.
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
'access' => [
'class' => AccessControl::className(),
'only' => ['index', 'view','create','update','delete'],
'rules' => [
[
'actions' => ['index','view'],
'allow' => true,
'roles' => ['?'],
],
[
'actions' => ['create','update','delete'],
'allow' => true,
'roles' => ['@'],
],
[
'allow' => false,
'verbs' => ['POST']
],
],
],
];
}
How can i define the rules based on which user is logged in???