forked from laravel-json-api/laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserPolicy.php
67 lines (59 loc) · 1.39 KB
/
UserPolicy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/*
* Copyright 2024 Cloud Creativity Limited
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
declare(strict_types=1);
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\Response;
class UserPolicy
{
/**
* Determine if the user can view the other user.
*
* @param User $user
* @param User $other
* @return bool
*/
public function view(User $user, User $other): bool
{
return true;
}
/**
* Determine if the user can view the other user's phone.
*
* @param User $user
* @param User $other
* @return bool
*/
public function viewPhone(User $user, User $other): bool
{
return $user->is($other);
}
/**
* Determine if the user can update the other user's phone.
*
* @param User $user
* @param User $other
* @return bool
*/
public function updatePhone(User $user, User $other): bool
{
return $user->is($other);
}
/**
* Determine if the user can delete the other user.
*
* @param ?User $user
* @param User $other
* @return bool|Response
*/
public function delete(?User $user, User $other)
{
return $user?->is($other) ? true : Response::denyAsNotFound('not found message');
}
}