Passed
Push — master ( 453af3...b6447c )
by Darko
09:30
created

PostPolicy   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 4
c 1
b 0
f 0
dl 0
loc 18
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A restore() 0 4 2
A edit() 0 4 2
A delete() 0 4 2
1
<?php
2
3
namespace App\Policies;
4
5
use TeamTeaTime\Forum\Models\Post;
6
7
class PostPolicy extends \TeamTeaTime\Forum\Policies\PostPolicy
8
{
9
    public function edit($user, Post $post): bool
10
    {
11
        // Admins can edit any post; users can edit their own
12
        return $user->hasRole('Admin') || ($user->getKey() === $post->author_id);
0 ignored issues
show
Bug introduced by
The property author_id does not seem to exist on TeamTeaTime\Forum\Models\Post. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
13
    }
14
15
    public function delete($user, Post $post): bool
16
    {
17
        // Admins can delete any post; users can delete their own
18
        return $user->hasRole('Admin') || ($user->getKey() === $post->author_id);
0 ignored issues
show
Bug introduced by
The property author_id does not seem to exist on TeamTeaTime\Forum\Models\Post. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
19
    }
20
21
    public function restore($user, Post $post): bool
22
    {
23
        // Admins can restore any post; users can restore their own
24
        return $user->hasRole('Admin') || ($user->getKey() === $post->author_id);
0 ignored issues
show
Bug introduced by
The property author_id does not seem to exist on TeamTeaTime\Forum\Models\Post. Are you sure there is no database migration missing?

Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.

Loading history...
25
    }
26
}
27