Passed
Push — 5.0.0 ( 757365...6c4e14 )
by Fèvre
05:11
created

BlogCategoryObserver   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A deleting() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Observers;
6
7
use Xetaravel\Models\BlogCategory;
8
9
class BlogCategoryObserver
10
{
11
12
    /**
13
     * Handle the "deleting" event.
14
     */
15
    public function deleting(BlogCategory $blogCategory): void
16
    {
17
        // We need to do this to refresh the countable cache `blog_comment_count` of the user.
18
        $blogCategory->loadMissing('articles');
19
        foreach ($blogCategory->articles as $article) {
20
            $article->delete();
21
        }
22
    }
23
}
24