28 lines
507 B
PHP
28 lines
507 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Policies;
|
||
|
|
||
|
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()
|
||
|
);
|
||
|
}
|
||
|
}
|