Code Duplication    Length = 45-45 lines in 2 locations

app/Policies/DiscussConversationPolicy.php 1 location

@@ 8-52 (lines=45) @@
5
use Xetaravel\Models\DiscussConversation;
6
use Illuminate\Auth\Access\HandlesAuthorization;
7
8
class DiscussConversationPolicy
9
{
10
    use HandlesAuthorization;
11
12
    /**
13
     * Authorize all actions if the user has the given permission.
14
     *
15
     * @param \Xetaravel\Models\User $user
16
     * @param string $ability
17
     *
18
     * @return true|void
19
     */
20
    public function before(User $user, string $ability)
21
    {
22
        if ($user->hasPermission('manage.discuss.conversations')) {
23
            return true;
24
        }
25
    }
26
27
    /**
28
     * Determine whether the user can update the discuss conversation.
29
     *
30
     * @param \Xetaravel\Models\User $user
31
     * @param \Xetaravel\Models\DiscussConversation $discussConversation
32
     *
33
     * @return bool
34
     */
35
    public function update(User $user, DiscussConversation $discussConversation)
36
    {
37
        return $user->id === $discussConversation->user_id;
38
    }
39
40
    /**
41
     * Determine whether the user can delete the discuss conversation.
42
     *
43
     * @param \Xetaravel\Models\User $user
44
     * @param \Xetaravel\Models\DiscussConversation $discussConversation
45
     *
46
     * @return bool
47
     */
48
    public function delete(User $user, DiscussConversation $discussConversation)
49
    {
50
        return $user->id === $discussConversation->user_id;
51
    }
52
}
53

app/Policies/DiscussPostPolicy.php 1 location

@@ 8-52 (lines=45) @@
5
use Xetaravel\Models\DiscussPost;
6
use Illuminate\Auth\Access\HandlesAuthorization;
7
8
class DiscussPostPolicy
9
{
10
    use HandlesAuthorization;
11
12
    /**
13
     * Authorize all actions if the user has the given permission.
14
     *
15
     * @param \Xetaravel\Models\User $user
16
     * @param string $ability
17
     *
18
     * @return true|void
19
     */
20
    public function before(User $user, string $ability)
21
    {
22
        if ($user->hasPermission('manage.discuss.posts')) {
23
            return true;
24
        }
25
    }
26
27
    /**
28
     * Determine whether the user can update the discuss post.
29
     *
30
     * @param \Xetaravel\Models\User $user
31
     * @param \Xetaravel\Models\DiscussPost $discussPost
32
     *
33
     * @return bool
34
     */
35
    public function update(User $user, DiscussPost $discussPost)
36
    {
37
        return $user->id === $discussPost->user_id;
38
    }
39
40
    /**
41
     * Determine whether the user can delete the discuss post.
42
     *
43
     * @param \Xetaravel\Models\User $user
44
     * @param \Xetaravel\Models\DiscussPost $discussPost
45
     *
46
     * @return bool
47
     */
48
    public function delete(User $user, DiscussPost $discussPost)
49
    {
50
        return $user->id === $discussPost->user_id;
51
    }
52
}
53