orchidsoftware / crud

Simplify the process of building CRUD (Create, Read, Update, Delete) functionality in Laravel using the features of Orchid.
https://orchid.software
MIT License
137 stars 34 forks source link

Hide default actions in ListScreen #51

Closed jlevers closed 3 years ago

jlevers commented 3 years ago

Thanks for all the great work on this project!

Is there a way to hide the default View and Update actions on each record in the list view? Currently it seems like the only real way to override anything in the ListScreen is to create a full custom screen.

tabuna commented 3 years ago

Hi, @jlevers. The CRUD build package relies on eloquent models where view or update permissions are granted by specifying a policy. To hide them, you need to create a policy for your model. For example:

namespace App\Policies;

use App\Models\User;
use App\Models\Post;
use Illuminate\Auth\Access\HandlesAuthorization;

class PostPolicy
{
    use HandlesAuthorization;

    /**
     * Determine whether the user can update the post.
     *
     * @param  User  $user
     * @param  Post  $post
     * @return mixed
     */
    public function update(User $user, Post $post)
    {
        return true;
    }
}

You can find more information on the package page and on the laravel documentation page.

jlevers commented 3 years ago

Gotcha -- that makes sense. Thank you!