Skip to content

Commit

Permalink
feature: add relation
Browse files Browse the repository at this point in the history
  • Loading branch information
achmadhadikurnia committed Apr 3, 2024
1 parent 7c6253d commit ca84836
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Models/ReferensiRefUnor.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Kanekescom\Siasn\Referensi\Models\Eselon;
use Kanekescom\Siasn\Referensi\Models\Instansi;

class ReferensiRefUnor extends Model
{
use HasFactory;
use SoftDeletes;

/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'Id';

/**
* The data type of the auto-incrementing ID.
*
Expand All @@ -33,4 +43,24 @@ public function getTable()
{
return 'siasn_simpeg_'.str(class_basename(__CLASS__))->snake();
}

public function instansi(): BelongsTo
{
return $this->belongsTo(Instansi::class, 'InstansiId');
}

public function diatasan(): BelongsTo
{
return $this->belongsTo(ReferensiRefUnor::class, 'DiatasanId');
}

public function eselon(): BelongsTo
{
return $this->belongsTo(Eselon::class, 'EselonId');
}

public function indukUnor(): BelongsTo
{
return $this->belongsTo(ReferensiRefUnor::class, 'IndukUnorId');
}
}

0 comments on commit ca84836

Please sign in to comment.