2026-01-19 06:37:37 +07:00
|
|
|
<?php
|
|
|
|
|
namespace App\Models\Master;
|
|
|
|
|
|
|
|
|
|
use App\Models\BaseModel;
|
|
|
|
|
|
|
|
|
|
class MasterTestsModel extends BaseModel {
|
|
|
|
|
protected $table = 'master_tests';
|
|
|
|
|
protected $primaryKey = 'test_id';
|
|
|
|
|
protected $allowedFields = [
|
|
|
|
|
'dept_id',
|
2026-01-21 13:41:37 +07:00
|
|
|
'test_code',
|
docs: add comprehensive documentation and refactor API structure
This commit introduces a complete documentation suite, refactors the API layer for
better consistency, and updates the database schema and seeding logic.
Key Changes:
- Documentation:
- Added `CLAUDE.md` with development guidelines and architecture overview.
- Created `docs/` directory with detailed guides for architecture, development,
and source tree analysis.
- Database & Migrations:
- Implemented `RenameMasterColumns` migration to standardize column naming
(e.g., `name` -> `dept_name`, `name` -> `control_name`).
- Added `CmodQcSeeder` to populate the system with realistic sample data
for depts, controls, tests, and results.
- Backend API:
- Created `DashboardApiController` with `getRecent()` for dashboard stats.
- Created `ReportApiController` for managed reporting access.
- Updated `app/Config/Routes.php` with new API groupings and documentation routes.
- Frontend & Views:
- Refactored master data views (`dept`, `test`, `control`) to use Alpine.js
and the updated API structure.
- Modernized `dashboard.php` and `main_layout.php` with improved UI/UX.
- Infrastructure:
- Updated `.gitignore` to exclude development-specific artifacts (`_bmad/`, `.claude/`).
2026-01-20 14:44:46 +07:00
|
|
|
'test_name',
|
|
|
|
|
'test_unit',
|
|
|
|
|
'test_method',
|
2026-01-19 06:37:37 +07:00
|
|
|
'cva',
|
|
|
|
|
'ba',
|
|
|
|
|
'tea',
|
|
|
|
|
'created_at',
|
|
|
|
|
'updated_at',
|
|
|
|
|
'deleted_at'
|
|
|
|
|
];
|
|
|
|
|
protected $useTimestamps = true;
|
|
|
|
|
protected $useSoftDeletes = true;
|
|
|
|
|
|
|
|
|
|
public function search($keyword = null) {
|
2026-01-21 13:41:37 +07:00
|
|
|
$builder = $this->builder();
|
|
|
|
|
$builder->select('
|
|
|
|
|
master_tests.test_id as testId,
|
|
|
|
|
master_tests.test_code as testCode,
|
|
|
|
|
master_tests.test_name as testName,
|
|
|
|
|
master_tests.test_unit as testUnit,
|
|
|
|
|
master_tests.test_method as testMethod,
|
|
|
|
|
master_tests.cva,
|
|
|
|
|
master_tests.ba,
|
|
|
|
|
master_tests.tea,
|
|
|
|
|
master_depts.dept_name as deptName
|
|
|
|
|
');
|
|
|
|
|
$builder->join('master_depts', 'master_depts.dept_id = master_tests.dept_id', 'left');
|
|
|
|
|
$builder->where('master_tests.deleted_at', null);
|
|
|
|
|
|
2026-01-19 06:37:37 +07:00
|
|
|
if ($keyword) {
|
2026-01-21 13:41:37 +07:00
|
|
|
$builder->groupStart()
|
|
|
|
|
->like('master_tests.test_name', $keyword)
|
|
|
|
|
->groupEnd();
|
2026-01-19 06:37:37 +07:00
|
|
|
}
|
2026-01-21 13:41:37 +07:00
|
|
|
|
|
|
|
|
$builder->groupBy('master_tests.test_id, master_depts.dept_name');
|
|
|
|
|
$builder->orderBy('master_tests.test_name', 'ASC');
|
|
|
|
|
|
|
|
|
|
return $builder->get()->getResultArray();
|
2026-01-19 06:37:37 +07:00
|
|
|
}
|
|
|
|
|
}
|