Enable ZC to see netmail in their zone, and point owners to see their own netmail
This commit is contained in:
35
app/Policies/NetmailPolicy.php
Normal file
35
app/Policies/NetmailPolicy.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\HandlesAuthorization;
|
||||
|
||||
use App\Models\{Netmail,User};
|
||||
|
||||
class NetmailPolicy
|
||||
{
|
||||
use HandlesAuthorization;
|
||||
|
||||
/**
|
||||
* This determines whether a logged-in user can view a netmail
|
||||
*
|
||||
* @param User $user
|
||||
* @param Netmail $netmail
|
||||
* @return bool
|
||||
*/
|
||||
public function view(User $user, Netmail $netmail): bool
|
||||
{
|
||||
$zones = $user->zc()->pluck('zone')
|
||||
//->merge($user->rc()->pluck('zone'))
|
||||
//->merge($user->nc()->pluck('zone'))
|
||||
//->merge($user->hub()->pluck('zone'))
|
||||
->merge($user->points()->pluck('zone'));
|
||||
|
||||
// Site Admins can always view
|
||||
return (
|
||||
$user->isAdmin()
|
||||
|| ($zones->contains($netmail->fftn->zone))
|
||||
|| ($zones->contains($netmail->tftn->zone))
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user