feat: add AnggotaKeluarga, RiwayatBantuan, PermohonanTransfer models and migrations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
GuavaPopper
2026-06-05 04:52:23 +07:00
parent 9bd5506f4f
commit e907100175
11 changed files with 210 additions and 2 deletions
+28
View File
@@ -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;
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class PermohonanTransfer extends Model
{
protected $table = 'permohonan_transfer';
protected $fillable = [
'dari_ibadah_id', 'ke_ibadah_id', 'id_rumah',
'alasan', 'status', 'catatan_respons',
'diajukan_oleh', 'diproses_oleh',
];
public function dariIbadah() { return $this->belongsTo(RumahIbadah::class, 'dari_ibadah_id'); }
public function keIbadah() { return $this->belongsTo(RumahIbadah::class, 'ke_ibadah_id'); }
public function rumahMiskin() { return $this->belongsTo(RumahMiskin::class, 'id_rumah', 'id_rumah'); }
public function pengaju() { return $this->belongsTo(User::class, 'diajukan_oleh'); }
public function pemroses() { return $this->belongsTo(User::class, 'diproses_oleh'); }
}
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class RiwayatBantuan extends Model
{
protected $table = 'riwayat_bantuan';
protected $fillable = [
'id_rumah', 'ibadah_id', 'dicatat_oleh',
'jenis_bantuan', 'keterangan', 'tanggal_bantuan',
];
protected $casts = ['tanggal_bantuan' => 'date'];
public function rumahMiskin() { return $this->belongsTo(RumahMiskin::class, 'id_rumah', 'id_rumah'); }
public function ibadah() { return $this->belongsTo(RumahIbadah::class, 'ibadah_id'); }
public function pencatat() { return $this->belongsTo(User::class, 'dicatat_oleh'); }
}
+5
View File
@@ -17,4 +17,9 @@ class RumahIbadah extends Model
{
return $this->belongsTo(\App\Models\User::class);
}
public function bantuanDiberikan()
{
return $this->hasMany(RiwayatBantuan::class, 'ibadah_id');
}
}
+11 -1
View File
@@ -14,5 +14,15 @@ class RumahMiskin extends Model
protected $primaryKey = 'id_rumah';
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = ['id_rumah', 'alamat', 'jumlah_kk', 'jumlah_orang', 'latitude', 'longitude'];
protected $fillable = ['id_rumah', 'nama_kk', 'alamat', 'jumlah_kk', 'jumlah_orang', 'latitude', 'longitude', 'pekerjaan', 'pendapatan', 'kondisi_rumah', 'keterangan'];
public function anggota()
{
return $this->hasMany(AnggotaKeluarga::class, 'id_rumah', 'id_rumah');
}
public function bantuan()
{
return $this->hasMany(RiwayatBantuan::class, 'id_rumah', 'id_rumah');
}
}