master

laravel/framework

Last updated at: 28/12/2023 01:35

policy.stub

TLDR

This file is a stub for generating policy classes in a Laravel application. It provides methods to determine user permissions for different model actions.

Methods

viewAny

This method determines whether the user can view any models.

view

This method determines whether the user can view a specific model.

create

This method determines whether the user can create models.

update

This method determines whether the user can update a specific model.

delete

This method determines whether the user can delete a specific model.

restore

This method determines whether the user can restore a deleted model.

forceDelete

This method determines whether the user can permanently delete a model.

<?php

namespace {{ namespace }};

use Illuminate\Auth\Access\Response;
use {{ namespacedModel }};
use {{ namespacedUserModel }};

class {{ class }}
{
    /**
     * Determine whether the user can view any models.
     */
    public function viewAny({{ user }} $user): bool
    {
        //
    }

    /**
     * Determine whether the user can view the model.
     */
    public function view({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
    {
        //
    }

    /**
     * Determine whether the user can create models.
     */
    public function create({{ user }} $user): bool
    {
        //
    }

    /**
     * Determine whether the user can update the model.
     */
    public function update({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
    {
        //
    }

    /**
     * Determine whether the user can delete the model.
     */
    public function delete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
    {
        //
    }

    /**
     * Determine whether the user can restore the model.
     */
    public function restore({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
    {
        //
    }

    /**
     * Determine whether the user can permanently delete the model.
     */
    public function forceDelete({{ user }} $user, {{ model }} ${{ modelVariable }}): bool
    {
        //
    }
}