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\DiscussPost;
use Illuminate\Auth\Access\HandlesAuthorization;
class DiscussPostPolicy
{
use HandlesAuthorization;
/**
* Authorize all actions if the user has the given permission.
*
* @param \Xetaravel\Models\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->hasPermission('manage.discuss.posts')) {
return true;
}
* Determine whether the user can update the discuss post.
* @param \Xetaravel\Models\DiscussPost $discussPost
* @return bool
public function update(User $user, DiscussPost $discussPost)
return $user->id === $discussPost->user_id;
* Determine whether the user can delete the discuss post.
public function delete(User $user, DiscussPost $discussPost)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.