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/otium.komma.nl/app/Buttons/ButtonPolicy.php
<?php

namespace App\Buttons;

use App\Buttons\Models\Button;
use Komma\KMS\Base\Policy;
use Komma\KMS\Users\Models\KmsUser;
use Komma\KMS\Users\Models\KmsUserRole;

final class ButtonPolicy extends Policy
{
    protected $modelClassName = Button::class;


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

    /**
     * Determine if it is allowed to view a specific resource
     *
     * @param KmsUser|null $user
     * @return bool
     */
    public function show(KmsUser $user, $modelToShow): bool
    {
        $result = $user->isAtLeast(KmsUserRole::SuperAdmin);
        $this->debug('show', $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 KmsUser|null $user
     * @return bool
     */
    public function edit(KmsUser $user, $modelToEdit): bool
    {
        $result = $user->isAtLeast(KmsUserRole::SuperAdmin);
        $this->debug('edit', $result);
        return $result;
    }

    /**
     * Determine if it is allowed to store a new resource
     * Usually made using a create form.
     *
     * @param KmsUser|null $user
     * @return bool
     */
    public function store(KmsUser $user): bool
    {
        $result = $user->isAtLeast(KmsUserRole::SuperAdmin);
        $this->debug('store', $result);
        return $result;
    }

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