Conditions | 2 |
Paths | 2 |
Total Lines | 12 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function beforeDelete(Event $event) |
||
19 | { |
||
20 | /** @var ArticleCategory $model */ |
||
21 | $model = $event->sender; |
||
22 | $count = Article::find() |
||
23 | ->where([ |
||
24 | 'category_id' => $model->id, |
||
25 | 'is_deleted' => 0, |
||
26 | ]) |
||
27 | ->count(); |
||
28 | if ($count > 0) { |
||
29 | throw new \Exception('Unable to delete category since there are articles belong to it'); |
||
30 | } |
||
33 |