Skip to content

Commit

Permalink
Merge pull request #27 from achmadhadikurnia/main
Browse files Browse the repository at this point in the history
feature: add relation
  • Loading branch information
achmadhadikurnia authored Apr 3, 2024
2 parents 85d80b1 + ca84836 commit b5d1083
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 b5d1083

Please sign in to comment.