freescout/freescout-dist/app/Policies/FolderPolicy.php

34 lines
711 B
PHP
Raw Normal View History

2023-12-22 19:40:32 +00:00
<?php
namespace App\Policies;
use App\Folder;
use App\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class FolderPolicy
{
use HandlesAuthorization;
/**
* Determine whether the user can view the folder.
*
* @param \App\User $user
* @param \App\Folder $folder
*
* @return bool
*/
public function view(User $user, Folder $folder)
{
if ($user->isAdmin()) {
return true;
} else {
if ($folder->user_id == $user->id || $user->mailboxesSettings()->pluck('mailbox_id')->contains($folder->mailbox_id)) {
return true;
} else {
return false;
}
}
}
}