35 lines
744 B
PHP
35 lines
744 B
PHP
<?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))
|
|
);
|
|
}
|
|
} |