82 lines
2.0 KiB
PHP
82 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Form extends Model
|
|
{
|
|
protected $table = 'status_form';
|
|
protected $primaryKey = 'id';
|
|
|
|
public $timestamps = true;
|
|
protected $fillable = [
|
|
'nama_form',
|
|
'jenis_form',
|
|
'semester',
|
|
'status',
|
|
'tanggal_pembuatan',
|
|
'kuota_penurunan',
|
|
'kuota_pengangsuran',
|
|
'tahun',
|
|
'tanggal_pembukaan',
|
|
'tanggal_penutupan',
|
|
'tanggal_verifikasi',
|
|
'tanggal_pengumuman'
|
|
|
|
];
|
|
|
|
protected $casts = [
|
|
'tanggal_pembuatan' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime',
|
|
'tanggal_pembukaan' => 'datetime',
|
|
'tanggal_penutupan' => 'datetime',
|
|
'tanggal_verifikasi' => 'datetime',
|
|
'tanggal_pengumuman' => 'datetime'
|
|
];
|
|
|
|
public function getStatusBadgeAttribute()
|
|
{
|
|
return $this->status == 'Dibuka'
|
|
? '<span class="badge badge-success">Dibuka</span>'
|
|
: '<span class="badge badge-danger">Ditutup</span>';
|
|
}
|
|
|
|
|
|
public function getKodeSemesterAttribute()
|
|
{
|
|
return $this->semester . '-' . $this->tahun;
|
|
}
|
|
|
|
public function getTahunAkademikAttribute()
|
|
{
|
|
if ($this->semester == 'Ganjil') {
|
|
return $this->tahun . '/' . ($this->tahun + 1);
|
|
}
|
|
return ($this->tahun - 1) . '/' . $this->tahun;
|
|
}
|
|
|
|
public function pengajuan()
|
|
{
|
|
return $this->hasMany(PengajuanUkt::class);
|
|
}
|
|
|
|
public function canSubmit($mahasiswaId)
|
|
{
|
|
$existing = $this->pengajuan()
|
|
->where('mahasiswa_id', $mahasiswaId)
|
|
->first();
|
|
|
|
return !$existing || $existing->status_validasi === 'tidak valid';
|
|
}
|
|
|
|
public function getKuotaAttribute()
|
|
{
|
|
return $this->jenis_form == 'penurunan'
|
|
? $this->kuota_penurunan
|
|
: $this->kuota_pengangsuran;
|
|
}
|
|
}
|