init backend presensi

This commit is contained in:
mwpn
2026-03-05 14:37:36 +07:00
commit b4fda6b9c9
319 changed files with 27261 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Modules\Auth\Models;
use CodeIgniter\Model;
/**
* User Role Model (pivot)
*/
class UserRoleModel extends Model
{
protected $table = 'user_roles';
// Use a simple primary key to avoid composite PK issues in Model internals.
// Database level tetap punya primary key (user_id, role_id) via migration.
protected $primaryKey = 'user_id';
protected $useAutoIncrement = false;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
'user_id',
'role_id',
];
protected $useTimestamps = false;
/**
* Get role IDs for a user
*
* @param int $userId
* @return array<int>
*/
public function getRoleIdsForUser(int $userId): array
{
$rows = $this->where('user_id', $userId)->findAll();
$ids = [];
foreach ($rows as $row) {
$ids[] = (int) $row['role_id'];
}
return $ids;
}
}