Initial commit - lms-v2 + CLAUDE.md
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Department extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'code'];
|
||||
|
||||
// public function users(): HasMany
|
||||
// {
|
||||
// return $this->hasMany(User::class);
|
||||
// }
|
||||
|
||||
// Relasi ke Posisi (dari tabel class_sections lama)
|
||||
public function positions()
|
||||
{
|
||||
return $this->belongsToMany(Position::class, 'department_position');
|
||||
}
|
||||
|
||||
// Relasi ke Karyawan (Users) untuk menghitung total karyawan di departemen ini
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class, 'department_id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user