43 lines
979 B
PHP
43 lines
979 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class penduduk extends Model
|
|
{
|
|
use HasFactory;
|
|
protected $table = 'penduduks';
|
|
protected $primaryKey = 'id_penduduk';
|
|
|
|
protected $fillable = [
|
|
|
|
'nik',
|
|
'nama',
|
|
'jenis_kelamin',
|
|
'desa',
|
|
'dusun',
|
|
'rw',
|
|
'rt',
|
|
|
|
];
|
|
protected $with = ['datasubkriteria'];
|
|
|
|
public function datasubkriteria():BelongsTo{
|
|
return $this->belongsTo(datakriteria::class, 'id_subkriteria');
|
|
}
|
|
public function alternatif()
|
|
{
|
|
return $this->hasOne(Alternatif::class, 'id_penduduk');
|
|
}
|
|
public function alternatifs():BelongsTo{
|
|
return $this->belongsTo(alternatif::class, 'id_penduduk');
|
|
}
|
|
public function rangking()
|
|
{
|
|
return $this->hasOne(Rangking::class, 'kode', 'kode');
|
|
}
|
|
}
|