BlogCategoryObserver   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

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

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
     * Handle the "deleting" event.
13
     */
14
    public function deleting(BlogCategory $blogCategory): void
15
    {
16
        // We need to do this to refresh the countable cache `blog_comment_count` of the user.
17
        $blogCategory->loadMissing('articles');
18
        foreach ($blogCategory->articles as $article) {
19
            $article->delete();
20
        }
21
    }
22
}
23