2023-12-18 02:00:04 +00:00
|
|
|
<?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
|
2023-12-19 00:45:11 +00:00
|
|
|
* @param Netmail $o
|
2023-12-18 02:00:04 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2023-12-19 00:45:11 +00:00
|
|
|
public function view(User $user, Netmail $o): bool
|
2023-12-18 02:00:04 +00:00
|
|
|
{
|
|
|
|
$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()
|
2023-12-19 00:45:11 +00:00
|
|
|
|| ($zones->contains($o->fftn->zone))
|
|
|
|
|| ($zones->contains($o->tftn->zone))
|
2023-12-18 02:00:04 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|