try
{
$activeCategory = NewsCategory::find()
->where(['name_en' => Yii::$app->request->get('category')])
->one();
$model = News::find()
->where(['newsCategory_id' => $activeCategory->id]);
} catch (Exception $ex) {
/* */
}
} catch (\Exception $ex) {
throw new NotFoundHttpException('Not found');
}
try
, $activeCategory = NewsCategory::find()
->where(['name_en' => Yii::$app->request->get('category')])
->one();
if(!$activeCategory) { // Или ошибка
throw new NotFoundException();
}
$id = $activeCategory->id; // Иначе всё ок