Currently our system has roles and permissions and its already been running for years. We’ve been using spatie/laravel-permission
package
Our permission name has the following format: can_permission_name
Anyway I’m creating a Laravel policy, let’s say UserPolicy
class UserPolicy
{
public function can_add_user(User $user): bool
{
return true;
}
}
And I have a method can_add_user
, and I added it as a middleware
Route::get("users/{user}", [UserController::class, "add"])->middleware(["can:can_add_user,user"]);
But I think appending can_
into the method doesn’t seem to be working. How can I make this work, I want to name the method in this format can_method_name
?