*/ protected $fillable = [ 'name', 'coupon_code', ]; /** * Perform any actions required after the model boots. * * @return void */ protected static function booted(): void { static::creating(function (self $model) { $model->assertFieldIsUnique('coupon_code', $model->coupon_code); }); static::updating(function () { throw new \RuntimeException('Updating an archived coupon is not authorized'); }); static::deleting(function () { throw new \RuntimeException('Deleting an archived coupon is not authorized'); }); } // * RELATIONS /** * ArchiveStat model relation * @return Illuminate\Database\Eloquent\Relations\HasMany */ public function archiveStat() { return $this->hasMany(ArchiveStat::class); } }