39 lines
963 B
PHP
39 lines
963 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\Blameable;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class KelompokKategori extends Model
|
|
{
|
|
use HasFactory, Blameable, SoftDeletes;
|
|
|
|
protected $table = 'kelompok_kategoris';
|
|
|
|
protected $fillable = [
|
|
'kategori_produk_id',
|
|
'nama_kelompok_kategori',
|
|
'kode_kelompok_kategori',
|
|
];
|
|
|
|
public function kategoriProduk()
|
|
{
|
|
return $this->hasOne(KategoriProduk::class, 'id', 'kategori_produk_id');
|
|
}
|
|
|
|
// kelompok kategori pivot
|
|
public function kelompokKategoriPivot()
|
|
{
|
|
return $this->hasMany(KelompokKategoriPivot::class, 'kelompok_kategori_id');
|
|
}
|
|
|
|
// menu terlaris
|
|
public function menuTerlaris()
|
|
{
|
|
return $this->belongsToMany(MenuTerlarisView::class, 'kelompok_kategori_pivots', 'kelompok_kategori_id', 'produk_id');
|
|
}
|
|
}
|