belongsTo(Penyakit::class, 'kode_penyakit', 'kode_penyakit'); } public function gejala() { return $this->belongsTo(Gejala::class, 'kode_gejala', 'kode_gejala'); } protected static function boot() { parent::boot(); static::creating(function ($rules) { $count = self::count() + 1; $rules->kode_basis = 'R' . str_pad($count, 2, '0', STR_PAD_LEFT); }); } }