Last updated on 19 Oct 2019
Berikut ini adalah contoh script untuk menghadle error delete data yang berelasi.
- Pertama guanakan metode try catch
- Lalu gunakan handle error bawaan Yii
IntegrityException
- Dibawah ini adalah contoh script cara menggunakannya
$model= $this->findModel($id);
try {
$model->delete();
} catch(\yii\db\IntegrityException $e) {
throw new \yii\web\ForbiddenHttpException('Could not delete this record.' . $e);
}