protected function findModel($id) { if (($model = Product::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function beforeDelete() { if (parent::beforeDelete()) { CategoryDetail::deleteAll(['category_id' => $this->id]); Product::deleteAll(['category_id' => $this->id]); return true; } else { return false; } }