54 lines
1.2 KiB
PHP
54 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Program;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
|
|
use App\Models\Program\Aktivitas;
|
|
|
|
class Target extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
protected $table = 'program_target';
|
|
|
|
protected $fillable = [
|
|
"variabel",
|
|
"tipe",
|
|
"target_integer",
|
|
"target_float",
|
|
"target_boolean",
|
|
"baseline_integer",
|
|
"baseline_float",
|
|
"baseline_boolean",
|
|
"realisasi_integer",
|
|
"realisasi_float",
|
|
"realisasi_boolean",
|
|
"aktivitas_id",
|
|
"tipe_realisasi",
|
|
"value_query",
|
|
"created_by",
|
|
"updated_by",
|
|
"deleted_by",
|
|
];
|
|
|
|
public function aktivitas(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Aktivitas::class, 'aktivitas_id', 'id');
|
|
}
|
|
|
|
public function realisasi(): HasMany
|
|
{
|
|
return $this->hasMany(Realisasi::class, 'target_id', 'id')->latest();
|
|
}
|
|
|
|
public function latestRealisasi(): HasOne
|
|
{
|
|
return $this->hasOne(Realisasi::class, 'target_id', 'id')->latest();
|
|
}
|
|
}
|