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