actionProfileWithReportPermission

This commit is contained in:
iIronside
2022-01-14 12:56:39 +03:00
parent b123d250e1
commit e09f38f24b
6 changed files with 454 additions and 19 deletions

View File

@ -221,16 +221,6 @@ class User extends ActiveRecord implements IdentityInterface
return $this->hasOne(UserCard::class, ['id_user' => 'id']);
}
// public function getManager()
// {
// return $this->hasOne(Manager::class, ['user_id' => 'id']);
// }
//
// public function getManagerEmployee()
// {
// return $this->hasMany(ManagerEmployee::className(), ['employee_id' => 'id']);
// }
public function getProjectUser()
{
return $this->hasMany(ProjectUser::className(), ['user_id' => 'id']);

View File

@ -26,7 +26,7 @@ class ProfileService
private function isMyProfile()
{
if ($this->id === $this->searcherID) {
if ($this->id == $this->searcherID) {
return true;
}
return false;
@ -38,7 +38,7 @@ class ProfileService
return false;
}
if ($this->findEmploee()) {
if ($this->isMyEmploee()) {
return true;
}
return false;
@ -46,16 +46,17 @@ class ProfileService
private function amIManager()
{
if (Manager::findOne($this->searcherID)) {
if (Manager::find()->where(['user_card_id' => $this->searcherID])->exists()) {
return true;
}
return false;
}
private function findEmploee()
private function isMyEmploee()
{
$manager = Manager::find()->where(['user_card_id' => $this->searcherID])->one();
$exist = ManagerEmployee::find()
->where(['manager_id' => $this->searcherID, 'user_card_id' => $this->id])
->where(['manager_id' => $manager->id, 'user_card_id' => $this->id])
->exists();
if ($exist) {