I have the following function,
public function actionUpdate_avaliacao($id)
{
$model = $this->findModel($id);
if (Yii::$app->user->can('premium')) {
// ...
if ($model->load(Yii::$app->request->post()) && $model->save()) {
// get the instance of the uploaded file1
$fileNameForm1 = $model->id;
$filenameForm1Name = $model->ano;
// $model->file1=UploadedFile::getInstance($model, 'file1');
if ($model->file1=UploadedFile::getInstance($model, 'file1')) {
$model->file1->saveAs('docs/obras_reclamacao/'.'reclamacao_'.$fileNameForm1.'_'.$filenameForm1Name. '.' . $model->file1->extension);
// save the path in db column
$model->update_file_um='docs/obras_reclamacao/'.'reclamacao_'.$fileNameForm1.'_'.$filenameForm1Name.'.'.$model->file1->extension;
$model->save();
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update_avaliacao', [
'model' => $model,
]);
}
} else {
return $this->render('view', [
'model' => $model,
]);
}
}`
My question is if instead of using the ‘premium’ rule in if (Yii :: $ app-> user-> can (‘premium’)) {
, I have a way to create an identical function but with the user’s indication, in concrete. In other words, create a condition of access to a resource exclusive for the user XXX.
I appreciate the help.