feat: add AnggotaKeluarga, RiwayatBantuan, PermohonanTransfer models and migrations
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class AnggotaKeluarga extends Model
|
||||
{
|
||||
protected $table = 'anggota_keluarga';
|
||||
protected $fillable = [
|
||||
'id_rumah', 'nama', 'hubungan', 'jenis_kelamin',
|
||||
'tanggal_lahir', 'pendidikan', 'status_hidup',
|
||||
];
|
||||
protected $casts = ['tanggal_lahir' => 'date'];
|
||||
|
||||
public function rumahMiskin()
|
||||
{
|
||||
return $this->belongsTo(RumahMiskin::class, 'id_rumah', 'id_rumah');
|
||||
}
|
||||
|
||||
public function getUmurAttribute(): ?int
|
||||
{
|
||||
return $this->tanggal_lahir
|
||||
? now()->diffInYears(Carbon::parse($this->tanggal_lahir))
|
||||
: null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user