Issues (264)

app/Policies/DiscussPostPolicy.php (1 issue)

Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Policies;
6
7
use Xetaravel\Models\User;
8
use Xetaravel\Models\DiscussPost;
9
use Illuminate\Auth\Access\HandlesAuthorization;
10
11
class DiscussPostPolicy
12
{
13
    use HandlesAuthorization;
14
15
    /**
16
     * Authorize all actions if the user has the given permission.
17
     *
18
     * @param User $user
19
     * @param string $ability
20
     *
21
     * @return true|void
22
     */
23
    public function before(User $user, string $ability)
0 ignored issues
show
The parameter $ability is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

23
    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.

Loading history...
24
    {
25
        if ($user->hasPermissionTo('manage discuss post')) {
26
            return true;
27
        }
28
    }
29
30
    /**
31
     * Determine whether the user can create a discuss post.
32
     *
33
     * @param User $user
34
     *
35
     * @return bool
36
     */
37
    public function create(User $user): bool
38
    {
39
        return $user->hasPermissionTo('create discuss post');
40
    }
41
42
    /**
43
     * Determine whether the user can update the discuss post.
44
     *
45
     * @param User $user
46
     * @param DiscussPost $discussPost
47
     *
48
     * @return bool
49
     */
50
    public function update(User $user, DiscussPost $discussPost): bool
51
    {
52
        return $user->id === $discussPost->user_id && $user->hasPermissionTo('update discuss post');
53
    }
54
55
    /**
56
     * Determine whether the user can delete the discuss post.
57
     *
58
     * @param User $user
59
     * @param DiscussPost $discussPost
60
     *
61
     * @return bool
62
     */
63
    public function delete(User $user, DiscussPost $discussPost): bool
64
    {
65
        return $user->id === $discussPost->user_id && $user->hasPermissionTo('delete discuss post');
66
    }
67
}
68