fix enrollment logic, add financial aid, fix class distribution
Tests / PHPUnit (push) Failing after 1m6s
Tests / PHPUnit (push) Failing after 1m6s
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class GrantEnrollmentExceptionPermission extends Migration
|
||||
{
|
||||
private string $permissionName = 'enrollment.exception.manage';
|
||||
|
||||
public function up()
|
||||
{
|
||||
if (! $this->db->tableExists('permissions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permission = $this->db->table('permissions')
|
||||
->where('name', $this->permissionName)
|
||||
->limit(1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if ($permission === null) {
|
||||
$insert = [
|
||||
'name' => $this->permissionName,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
'updated_at' => date('Y-m-d H:i:s'),
|
||||
];
|
||||
if ($this->db->fieldExists('description', 'permissions')) {
|
||||
$insert['description'] = 'Manage scoped enrollment eligibility exceptions.';
|
||||
}
|
||||
$this->db->table('permissions')->insert($insert);
|
||||
$permissionId = (int) $this->db->insertID();
|
||||
} else {
|
||||
$permissionId = (int) $permission['id'];
|
||||
}
|
||||
|
||||
// The plan requires a narrow permission but not an automatic broad role grant.
|
||||
// Assign enrollment.exception.manage through the existing role-permission UI.
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
if (! $this->db->tableExists('permissions') || ! $this->db->tableExists('role_permissions')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$permission = $this->db->table('permissions')
|
||||
->where('name', $this->permissionName)
|
||||
->limit(1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
if ($permission === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->db->table('role_permissions')
|
||||
->where('permission_id', (int) $permission['id'])
|
||||
->delete();
|
||||
$this->db->table('permissions')
|
||||
->where('id', (int) $permission['id'])
|
||||
->delete();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user