but the part that concern Using rule, i want to know how name the files (with specific code) and where put those files in order to implement the updateownpost.
1. in C:\wamp\www\Projet_pred\controllers\FiliereEtabController.php at line 95
8687888990919293949596979899100101102103104
/**
* Updates an existing FiliereEtab model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
if (\Yii::$app->user->can('updatePost', ['post' => $post])) {
$isStudent = Yii::$app->session->get('user_id'); //echo $isStudent;
$mode= FiliereEtab::find()->andWhere(['id_etab'=>$isStudent])->one();
$id = $mode->id_fil;
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_fil]);
} else {
return $this->render('update',
i implement the rule by following this link instructions http://www.yiiframework.com/doc-2.0/guide-security-authorization.html
and i have to my databse, in table auth_rule this line
name : isAuthor
data: O:19:"app\rbac\AuthorRule":3:{s:4:"name";s:8:"isAuthor";s:9:"createdAt";i:1456917036;s:9:"updatedAt";i:1456917036;}
after, for my example, i take all line of a table (my ex: filieretab) in database, that put by an user to variable $post
Note that “$params[‘post’]” must be an ActiveRecord object that represents the current blog post in that particular sample scenario.
Are you handing blog posts? No. Your are dealing with “Etab” or something like that. Why don’t you adjust the example to your project? Just copy-and-pasting will never do the job for you. Try harder to understand how things work.
Anyway, you have to pass a single instance of object to the rule. You are trying to pass an array of objects.