HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/SiteConfig/SiteConfigPolicy.php
<?php

namespace App\Komma\SiteConfig;

use App\Komma\Base\Policy;
use App\Komma\SiteConfig\Models\SiteConfig;
use App\Komma\Users\Models\Role;
use App\Komma\Users\Models\User;

final class SiteConfigPolicy extends Policy
{
    protected $forModelName = SiteConfig::class;

    /**
     * Determine if it is allowed to view all resources
     *
     * @param User|null $user
     * @return bool
     */
    public function index(?User $user): bool
    {
        $result = $user->role->isAtLeast(Role::Admin);
        $this->debug('index', $result);

        return $result;
    }

    /**
     * Determine if it is allowed show a form to edit a resource.
     * This usually means that the user did view the model to be edited and got past
     * the show authorisation. Then he edited a form to change the model and pressed
     * save. After he pressed save he will trigger this edit authorisation
     *
     * @param User|null $user
     * @return bool
     */
    public function edit(?User $user, $modelToEdit): bool
    {
        $result = $user->role->isAtLeast(Role::Admin);
        $this->debug('edit', $result);

        return $result;
    }

    /**
     * Determine if it is allowed to show a form for creating a new resource
     *
     * @param User|null $user
     * @return bool
     */
    public function create(?User $user): bool
    {
        $result = $user->role->isAtLeast(Role::SuperAdmin);
        $this->debug('create', $result);

        return $result;
    }

    /**
     * Determine if it is allowed to update an existing resource after editing it
     *
     * @param User|null $user
     * @return bool
     */
    public function update(?User $user): bool
    {
        $result = $user->role->isAtLeast(Role::Admin);
        $this->debug('update', $result);

        return $result;
    }

    /**
     * Determine if it is allowed to destroy an existing resource
     *
     * @param User|null $user
     * @return bool
     */
    public function destroy(?User $user, $modelToDestroy): bool
    {
        $result = $user->role->isAtLeast(Role::SuperAdmin);
        $this->debug('destroy', $result);

        return $result;
    }
}