Reputation: 3119
I'm very very new to Yii & creating a web application that deals with Users & Groups with Yii advanced app framework.
Currently I have finished all database part & creating models & CRUD operations with the gii tool.
Here is my related databases (user_group.group_owner_id ----> user.id
)
Problem :
When I navigate to User groups page it shows all the groups of all the users.
but I want to show only the groups that he made.
So I customized the UserGroupSearch
model as follows, but it throws a syntax error.
UserGroupSearch.php
public function search($params)
{
$current_logged_user_id = Yii::$app->user->identity->id; //get the id of the current user
$query = UserGroup::find()->where(['group_owner_id' = $current_logged_user_id]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
//other codes
}
Error :
PHP Parse Error – yii\base\ErrorException
syntax error, unexpected '=', expecting ']'
error line number shows as the line with with the where clause
Upvotes: 1
Views: 203
Reputation: 2012
where(['group_owner_id' = $current_logged_user_id])
need change to
where(['group_owner_id' => $current_logged_user_id])
Upvotes: 2