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

PostPolicy::delete()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 2
nc 2
nop 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