for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Xetaravel\Policies;
use Xetaravel\Models\User;
use Xetaravel\Models\BlogComment;
use Illuminate\Auth\Access\HandlesAuthorization;
class BlogCommentPolicy
{
use HandlesAuthorization;
/**
* Authorize all actions if the user has the given permission.
*
* @param User $user
* @param string $ability
* @return true|void
*/
public function before(User $user, string $ability)
$ability
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function before(User $user, /** @scrutinizer ignore-unused */ string $ability)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
if ($user->hasPermissionTo('manage blog article')) {
return true;
}
* Determine whether the user can create a blog comment.
* @param BlogComment $comment
* @return bool
public function create(User $user, BlogComment $comment): bool
$comment
public function create(User $user, /** @scrutinizer ignore-unused */ BlogComment $comment): bool
return $user->hasPermissionTo('create blog comment');
* Determine whether the user can update the discuss post.
public function update(User $user, BlogComment $comment): bool
return $user->id === $comment->user_id;
* Determine whether the user can delete the discuss post.
public function delete(User $user, BlogComment $comment): bool
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.