NNTmux /
newznab-tmux
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Policies; |
||
| 4 | |||
| 5 | use TeamTeaTime\Forum\Models\Thread; |
||
| 6 | |||
| 7 | class ThreadPolicy extends \TeamTeaTime\Forum\Policies\ThreadPolicy |
||
| 8 | { |
||
| 9 | public function view($user, Thread $thread): bool |
||
| 10 | { |
||
| 11 | // Everyone (including Admin) can view by default |
||
| 12 | return parent::view($user, $thread); |
||
| 13 | } |
||
| 14 | |||
| 15 | public function rename($user, Thread $thread): bool |
||
| 16 | { |
||
| 17 | // Admins can rename any thread; users can rename their own |
||
| 18 | return $user->hasRole('Admin') || ($user->getKey() === $thread->author_id); |
||
|
0 ignored issues
–
show
|
|||
| 19 | } |
||
| 20 | |||
| 21 | public function reply($user, Thread $thread): bool |
||
| 22 | { |
||
| 23 | // Admins can reply even if locked; otherwise respect lock state |
||
| 24 | return $user->hasRole('Admin') || (! $thread->locked); |
||
| 25 | } |
||
| 26 | |||
| 27 | public function delete($user, Thread $thread): bool |
||
| 28 | { |
||
| 29 | // Admins can delete any thread; users can delete their own |
||
| 30 | return $user->hasRole('Admin') || ($user->getKey() === $thread->author_id); |
||
|
0 ignored issues
–
show
|
|||
| 31 | } |
||
| 32 | |||
| 33 | public function restore($user, Thread $thread): bool |
||
| 34 | { |
||
| 35 | // Admins can restore any thread; users can restore their own |
||
| 36 | return $user->hasRole('Admin') || ($user->getKey() === $thread->author_id); |
||
|
0 ignored issues
–
show
|
|||
| 37 | } |
||
| 38 | |||
| 39 | public function deletePosts($user, Thread $thread): bool |
||
| 40 | { |
||
| 41 | // Admins can delete posts in any thread; otherwise fall back to default (true) |
||
| 42 | return $user->hasRole('Admin') || parent::deletePosts($user, $thread); |
||
| 43 | } |
||
| 44 | |||
| 45 | public function restorePosts($user, Thread $thread): bool |
||
| 46 | { |
||
| 47 | // Admins can restore posts in any thread; otherwise fall back to default (true) |
||
| 48 | return $user->hasRole('Admin') || parent::restorePosts($user, $thread); |
||
| 49 | } |
||
| 50 | } |
||
| 51 |
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.