kei_mx's avatar

kei_mx wrote a comment+100 XP

2d ago

kei_mx's avatar

kei_mx liked a comment+100 XP

1w ago

Question About Adding Custom Methods in Laravel Policies

Absolutely, you can add custom methods to your Laravel policies beyond the default ones like view, create, update, and delete.

For example, if you want to add a method like createOwn to only allow users to create resources they "own," you can define it just like any other policy method:

public function createOwn(User $user, SomeModel $model)
{
    return $user->id === $model->user_id;
}

Once you've added a custom method, you can authorize it in your controllers/blades using:

$this->authorize('createOwn', $model);
// or
@can('createOwn', $model)
    <!-- show create button -->
@endcan

So, you are not limited to the default methods. Feel free to add authorization logic that fits your application's needs!

kei_mx's avatar

kei_mx liked a comment+100 XP

4mos ago

Laravel From Scratch (2026 Edition): Ep 2, Set Up Your Development Environment

First <3

@Jeffrey Way can you release a series on how to deploy a Laravel app with Docker in 2026 (maybe FrankenPHP)?

kei_mx's avatar

kei_mx wrote a reply+100 XP

4mos ago

Test Spatie Permissions with Orchestra Testbench policy

Hello.

First of all, why use permissions in your package?