PHP code example of trinityrank / nova-resource-remove

1. Go to this page and download the library: Download trinityrank/nova-resource-remove library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

trinityrank / nova-resource-remove example snippets

shell
    public function actions(Request $request)
    {
        return [
            (new NovaResourceRemove(
                ['\App\Models\Types\Category', 'category_id', ['categoriables']]
            ))->confirmButtonText('Remove Category')->onlyOnTableRow()
        ];
    }
shell
    public function actions(Request $request)
    {
        return [
            (new  NovaResourceRemove(
                ['\App\Models\User', 'user_id', ['pages','articles']]
            ))->canSee(function ($request) {
                return !$this->model()->hasRole(['Super Admin']);
            })->confirmButtonText('Remove User')->onlyOnTableRow()
        ];
    }
shell
    

	namespace App\Policies;

	use App\Models\Types\Category;
	use App\Models\User;
	use Illuminate\Auth\Access\HandlesAuthorization;

	class CategoryPolicy
	{
	    use HandlesAuthorization;

	    /**
	     * Determine whether the user can view any models.
	     *
	     * @param  \App\Models\User  $user
	     * @return \Illuminate\Auth\Access\Response|bool
	     */
	    public function viewAny(User $user)
	    {
	        return true;
	    }

	    /**
	     * Determine whether the user can view the model.
	     *
	     * @param  \App\Models\User  $user
	     * @param  \App\Models\Category  $category
	     * @return \Illuminate\Auth\Access\Response|bool
	     */
	    public function view(User $user, Category $category)
	    {
	        return true;
	    }

	    /**
	     * Determine whether the user can create models.
	     *
	     * @param  \App\Models\User  $user
	     * @return \Illuminate\Auth\Access\Response|bool
	     */
	    public function create(User $user)
	    {
	        return true;
	    }

	    /**
	     * Determine whether the user can update the model.
	     *
	     * @param  \App\Models\User  $user
	     * @param  \App\Models\Category  $category
	     * @return \Illuminate\Auth\Access\Response|bool
	     */
	    public function update(User $user, Category $category)
	    {
	        return true;
	    }

	    /**
	     * Determine whether the user can delete the model.
	     *
	     * @param  \App\Models\User  $user
	     * @param  \App\Models\Category  $category
	     * @return \Illuminate\Auth\Access\Response|bool
	     */
	    public function delete(User $user, Category $category)
	    {
	        return false;
	    }
	}