1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Policies; |
4
|
|
|
|
5
|
|
|
use App\Models\TechTipComment; |
6
|
|
|
use App\Models\User; |
7
|
|
|
use App\Traits\AllowTrait; |
8
|
|
|
use Illuminate\Auth\Access\HandlesAuthorization; |
9
|
|
|
|
10
|
|
|
class TechTipCommentPolicy |
11
|
|
|
{ |
12
|
|
|
use HandlesAuthorization; |
13
|
|
|
use AllowTrait; |
|
|
|
|
14
|
|
|
|
15
|
|
|
public function manage(User $user) |
16
|
|
|
{ |
17
|
|
|
return $this->checkPermission($user, 'Manage Tech Tips'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Determine whether the user can create models. |
22
|
|
|
* |
23
|
|
|
* @param \App\Models\User $user |
24
|
|
|
* @return mixed |
25
|
|
|
*/ |
26
|
|
|
public function create(User $user) |
27
|
|
|
{ |
28
|
|
|
return $this->checkPermission($user, 'Comment on Tech Tip'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Determine whether the user can update the model. |
33
|
|
|
* |
34
|
|
|
* @param \App\Models\User $user |
35
|
|
|
* @param \App\Models\TechTipComment $techTipComment |
36
|
|
|
* @return mixed |
37
|
|
|
*/ |
38
|
|
|
public function update(User $user, TechTipComment $techTipComment) |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
// |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Determine whether the user can delete the model. |
45
|
|
|
* |
46
|
|
|
* @param \App\Models\User $user |
47
|
|
|
* @param \App\Models\TechTipComment $techTipComment |
48
|
|
|
* @return mixed |
49
|
|
|
*/ |
50
|
|
|
public function delete(User $user, TechTipComment $techTipComment) |
51
|
|
|
{ |
52
|
|
|
if($this->checkPermission($user, 'Manage Tech Tips')) |
53
|
|
|
{ |
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
return $user->user_id === $techTipComment->user_id; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Determine whether the user can restore the model. |
62
|
|
|
* |
63
|
|
|
* @param \App\Models\User $user |
64
|
|
|
* @param \App\Models\TechTipComment $techTipComment |
65
|
|
|
* @return mixed |
66
|
|
|
*/ |
67
|
|
|
public function restore(User $user, TechTipComment $techTipComment) |
|
|
|
|
68
|
|
|
{ |
69
|
|
|
// |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Determine whether the user can permanently delete the model. |
74
|
|
|
* |
75
|
|
|
* @param \App\Models\User $user |
76
|
|
|
* @param \App\Models\TechTipComment $techTipComment |
77
|
|
|
* @return mixed |
78
|
|
|
*/ |
79
|
|
|
public function forceDelete(User $user, TechTipComment $techTipComment) |
|
|
|
|
80
|
|
|
{ |
81
|
|
|
// |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|