hasMany(Rule::class, 'kode_gejala', 'kode_gejala'); } protected static function boot() { parent::boot(); static::creating(function ($gejala) { $count = self::count() + 1; $gejala->kode_gejala = 'G' . str_pad($count, 2, '0', STR_PAD_LEFT); }); } }