2023-12-19 00:45:11 +00:00
|
|
|
<?php
|
|
|
|
|
2024-11-04 07:25:49 +00:00
|
|
|
namespace App\Models\Policies;
|
2023-12-19 00:45:11 +00:00
|
|
|
|
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
|
|
|
|
|
|
|
use App\Models\{Echomail,User};
|
|
|
|
|
|
|
|
class EchomailPolicy
|
|
|
|
{
|
|
|
|
use HandlesAuthorization;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This determines whether a logged-in user can view an echomail
|
|
|
|
*
|
|
|
|
* @param User $user
|
|
|
|
* @param Echomail $o
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function view(User $user, Echomail $o): bool
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
$user->isAdmin()
|
|
|
|
|| $user->isZC()
|
|
|
|
|| $o->seenby->pluck('id')->intersect($user->addresses()->pluck('id'))->count()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|