HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: /home/xedaptot/ai.naniguide.com/app/Policies/SegmentPolicy.php
<?php

namespace App\Policies;

use Illuminate\Auth\Access\HandlesAuthorization;
use App\Model\User;
use App\Model\Segment;

class SegmentPolicy
{
    use HandlesAuthorization;

    public function list(User $user)
    {
        if (app_profile('list.disable_segment') === true) {
            return false;
        }

        return true;
    }

    public function create(User $user, Segment $item)
    {
        // RBAC check
        if ($user->hasPermission('account.read_only')) {
            return false;
        }

        if (app_profile('list.disable_segment') === true) {
            return false;
        }

        // Ownership only. Segment quota check is in QuotaGate (called at controller boundary).
        return $user->customer->id == $item->mailList->customer_id;
    }

    public function update(User $user, Segment $item)
    {
        // RBAC check
        if ($user->hasPermission('account.read_only')) {
            return false;
        }

        if (app_profile('list.disable_segment') === true) {
            return false;
        }

        $customer = $user->customer;
        return $item->mailList->customer_id == $customer->id;
    }

    public function delete(User $user, Segment $item)
    {
        // RBAC check
        if ($user->hasPermission('account.read_only')) {
            return false;
        }

        if (app_profile('list.disable_segment') === true) {
            return false;
        }

        $customer = $user->customer;
        return $item->mailList->customer_id == $customer->id;
    }

    public function export(User $user, Segment $item)
    {
        // RBAC check
        if ($user->hasPermission('account.read_only')) {
            return false;
        }

        if (app_profile('list.disable_segment') === true) {
            return false;
        }

        $customer = $user->customer;
        return $item->mailList->customer_id == $customer->id;
    }
}