program dan basis data ekosistem
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use App\Models\Pertanian\Komoditas;
|
||||
|
||||
class KomoditasProgram extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'core_program_komoditas';
|
||||
|
||||
protected $fillable = [
|
||||
"program_id",
|
||||
"komoditas_id",
|
||||
"default",
|
||||
];
|
||||
|
||||
public function komoditas(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Komoditas::class, 'komoditas_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use App\Models\Wilayah\Provinsi;
|
||||
use App\Models\Wilayah\KabupatenKota;
|
||||
use App\Models\Wilayah\Kecamatan;
|
||||
use App\Models\Wilayah\DesaKelurahan;
|
||||
|
||||
class LokasiProgram extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'core_program_lokasi';
|
||||
|
||||
protected $fillable = [
|
||||
"program_id",
|
||||
"provinsi_id",
|
||||
"kabupaten_kota_id",
|
||||
"kecamatan_id",
|
||||
"desa_kelurahan_id",
|
||||
"default",
|
||||
];
|
||||
|
||||
public function provinsi(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Provinsi::class, 'provinsi_id');
|
||||
}
|
||||
|
||||
public function kabupatenKota(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(KabupatenKota::class, 'kabupaten_kota_id');
|
||||
}
|
||||
|
||||
public function kecamatan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Kecamatan::class, 'kecamatan_id');
|
||||
}
|
||||
|
||||
public function desaKelurahan(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(DesaKelurahan::class, 'desa_kelurahan_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Core;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
use App\Models\Core\KomoditasProgram;
|
||||
use App\Models\Core\LokasiProgram;
|
||||
|
||||
class Program extends Model
|
||||
{
|
||||
use SoftDeletes;
|
||||
|
||||
protected $table = 'core_program';
|
||||
|
||||
protected $fillable = [
|
||||
"nama",
|
||||
"sub_domain",
|
||||
"tahun",
|
||||
"instansi",
|
||||
];
|
||||
|
||||
public function komoditas(): HasMany
|
||||
{
|
||||
return $this->hasMany(KomoditasProgram::class, 'program_id', 'id');
|
||||
}
|
||||
|
||||
public function lokasi(): HasMany
|
||||
{
|
||||
return $this->hasMany(LokasiProgram::class, 'program_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user