Issues (264)

app/Policies/DiscussConversationPolicy.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\DiscussConversation;
9
use Illuminate\Auth\Access\HandlesAuthorization;
10
11
class DiscussConversationPolicy
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 conversation')) {
26
            return true;
27
        }
28
    }
29
30
    /**
31
     * Determine whether the user can create a discuss conversation.
32
     *
33
     * @param User $user
34
     *
35
     * @return bool
36
     */
37
    public function create(User $user): bool
38
    {
39
        return $user->hasPermissionTo('create discuss conversation');
40
    }
41
42
    /**
43
     * Determine whether the user can update the discuss conversation.
44
     *
45
     * @param User $user
46
     * @param DiscussConversation $discussConversation
47
     *
48
     * @return bool
49
     */
50
    public function update(User $user, DiscussConversation $discussConversation): bool
51
    {
52
        return $user->id === $discussConversation->user_id && $user->hasPermissionTo('update discuss conversation');
53
    }
54
55
    /**
56
     * Determine whether the user can delete the discuss conversation.
57
     *
58
     * @param User $user
59
     * @param DiscussConversation $discussConversation
60
     *
61
     * @return bool
62
     */
63
    public function delete(User $user, DiscussConversation $discussConversation): bool
64
    {
65
        return $user->id === $discussConversation->user_id && $user->hasPermissionTo('delete discuss conversation');
66
    }
67
68
    /**
69
     * Determine whether the user can make a discuss post as solved.
70
     * User must be the creator of the conversation to be able to make a
71
     * post as solved.
72
     *
73
     * @param User $user
74
     * @param DiscussConversation $discussConversation
75
     *
76
     * @return bool
77
     */
78
    public function solved(User $user, DiscussConversation $discussConversation): bool
79
    {
80
        return $user->id === $discussConversation->user_id;
81
    }
82
83
    /**
84
     * Determine whether the user can pin a conversation.
85
     *
86
     * @param User $user
87
     *
88
     * @return bool
89
     */
90
    public function pin(User $user): bool
91
    {
92
        return $user->hasPermissionTo('pin discuss conversation');
93
    }
94
95
    /**
96
     * Determine whether the user can lock a conversation.
97
     *
98
     * @param User $user
99
     *
100
     * @return bool
101
     */
102
    public function lock(User $user): bool
103
    {
104
        return $user->hasPermissionTo('lock discuss conversation');
105
    }
106
}
107