MIF_E31221225/app/Models/Mapel.php

40 lines
819 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Mapel extends Model
{
use HasFactory;
protected $table = 'mapels';
protected $fillable = [
'nama_mapel',
];
// App\Models\Mapel.php
public function kelas()
{
return $this->belongsToMany(Kelas::class, 'kelas_mapel');
}
public function paketMapel()
{
return $this->belongsToMany(PaketMapel::class, 'paket_mapel_detail');
}
public function guru()
{
return $this->belongsToMany(Guru::class, 'guru_mapel');
}
public function guruMapel()
{
// 'mapel_id' is the foreign key on the 'guru_mapel' table that links back to 'mapels' table.
return $this->hasMany(GuruMapel::class, 'mapel_id');
}
}