Issues (41)

app/Policies/TasksPolicy.php (4 issues)

1
<?php
2
3
namespace TaskManager\Policies;
4
5
use Hamcrest\SampleSelfDescriber;
6
use Psy\Util\Str;
7
use TaskManager\User;
8
use TaskManager\Tasks;
9
use Illuminate\Auth\Access\HandlesAuthorization;
10
11
class TasksPolicy
12
{
13
    use HandlesAuthorization;
14
15
    /**
16
     * Determine whether the user can view the tasks.
17
     *
18
     * @param  \TaskManager\User  $user
19
     * @param  \TaskManager\Tasks  $tasks
20
     * @return mixed
21
     */
22
    public function view(User $user, Tasks $tasks)
0 ignored issues
show
The parameter $user 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

22
    public function view(/** @scrutinizer ignore-unused */ User $user, Tasks $tasks)

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...
23
    {
24
       return dd($tasks);
25
26
    }
27
28
    /**
29
     * Determine whether the user can create tasks.
30
     *
31
     * @param  \TaskManager\User  $user
32
     * @return mixed
33
     */
34
    public function create(User $user)
35
    {
36
        if ($user->active)
0 ignored issues
show
Bug Best Practice introduced by
The property active does not exist on TaskManager\User. Since you implemented __get, consider adding a @property annotation.
Loading history...
37
            return true;
38
39
        else
40
            return false;
41
    }
42
43
44
    /**
45
     * Determine whether the user can update the tasks.
46
     *
47
     * @param  \TaskManager\User  $user
48
     * @param  \TaskManager\Tasks  $tasks
49
     * @return mixed
50
     */
51
    public function update(User $user, Tasks $task)
52
    {
53
        if($user->id == $task->user_id){
0 ignored issues
show
The property user_id does not exist on TaskManager\Tasks. Did you mean user?
Loading history...
54
            return true;
55
        }
56
        else{
57
            return false;
58
        }
59
    }
60
61
    /**
62
     * Determine whether the user can delete the tasks.
63
     *
64
     * @param  \TaskManager\User $user
65
     * @param Tasks $id
66
     * @return mixed
67
     * @internal param Tasks $tasks
68
     */
69
    public function delete(User $user, Tasks $id)
70
    {
71
72
        if($user->id == $id->user_id){
0 ignored issues
show
The property user_id does not exist on TaskManager\Tasks. Did you mean user?
Loading history...
73
            return true;
74
        }
75
        else{
76
            return false;
77
        }
78
79
    }
80
}
81