remove codeigniter
This commit is contained in:
@@ -10,7 +10,7 @@ class AdditionalCharge extends BaseModel
|
||||
{
|
||||
protected $table = 'additional_charges';
|
||||
|
||||
// CI useTimestamps = false
|
||||
// legacy useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -90,7 +90,7 @@ class AdditionalCharge extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI methods equivalents
|
||||
* legacy methods equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function byParentTerm(int $parentId, string $year, string $sem, ?string $status = null)
|
||||
|
||||
@@ -15,7 +15,7 @@ class AdminNotificationSubject extends BaseModel
|
||||
'updated_at',
|
||||
];
|
||||
|
||||
// CI uses created_at / updated_at
|
||||
// legacy uses created_at / updated_at
|
||||
public $timestamps = true;
|
||||
protected $casts = [
|
||||
'admin_id' => 'integer',
|
||||
|
||||
@@ -8,7 +8,7 @@ class AttendanceCommentTemplate extends BaseModel
|
||||
{
|
||||
protected $table = 'attendance_comment_template';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -27,7 +27,7 @@ class AttendanceCommentTemplate extends BaseModel
|
||||
];
|
||||
|
||||
/**
|
||||
* Equivalent of CI getActiveTemplates():
|
||||
* Equivalent of legacy getActiveTemplates():
|
||||
* is_active=1, order by min_score DESC
|
||||
*/
|
||||
public static function getActiveTemplates()
|
||||
|
||||
@@ -63,7 +63,7 @@ class AttendanceData extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,8 +10,8 @@ class AttendanceDay extends BaseModel
|
||||
{
|
||||
protected $table = 'attendance_day';
|
||||
|
||||
// ✅ You are storing created_at / updated_at manually in CI (timestamps off there)
|
||||
// User didn't explicitly ask to auto-manage here, so we keep it OFF to match CI.
|
||||
// ✅ You are storing created_at / updated_at manually in legacy (timestamps off there)
|
||||
// User didn't explicitly ask to auto-manage here, so we keep it OFF to match legacy.
|
||||
// If you want auto-manage, tell me and I’ll flip it.
|
||||
public $timestamps = false;
|
||||
|
||||
@@ -56,7 +56,7 @@ class AttendanceDay extends BaseModel
|
||||
];
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ class AttendanceRecord extends BaseModel
|
||||
{
|
||||
protected $table = 'attendance_record';
|
||||
|
||||
// ✅ CI uses created_at / updated_at
|
||||
// ✅ legacy uses created_at / updated_at
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -52,7 +52,7 @@ class AttendanceRecord extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
@@ -123,7 +123,7 @@ class AttendanceRecord extends BaseModel
|
||||
->where('school_year', $schoolYear)
|
||||
->update($update);
|
||||
|
||||
// If no record exists, return false (same idea as your CI code)
|
||||
// If no record exists, return false (same idea as your legacy code)
|
||||
return $affected > 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ class AttendanceTracking extends BaseModel
|
||||
{
|
||||
protected $table = 'attendance_tracking';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -27,7 +27,7 @@ class AttendanceTracking extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
'student_id' => 'integer',
|
||||
'date' => 'datetime', // CI dateFormat = datetime
|
||||
'date' => 'datetime', // legacy dateFormat = datetime
|
||||
'is_reported' => 'integer',
|
||||
'is_notified' => 'integer',
|
||||
'notif_counter' => 'integer',
|
||||
@@ -245,7 +245,7 @@ class AttendanceTracking extends BaseModel
|
||||
|
||||
/**
|
||||
* TRUE if at least $absencesThreshold absences in the last $weeksStreak weeks.
|
||||
* (Mirrors your CI behavior: count of last N fetched records)
|
||||
* (Mirrors your legacy behavior: count of last N fetched records)
|
||||
*/
|
||||
public static function checkAbsencesInStreak(
|
||||
int $studentId,
|
||||
|
||||
@@ -11,7 +11,7 @@ class BadgePrintLog extends BaseModel
|
||||
{
|
||||
protected $table = 'badge_print_logs';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -71,7 +71,7 @@ class BadgePrintLog extends BaseModel
|
||||
if (empty($rows)) return 0;
|
||||
|
||||
try {
|
||||
// insert returns bool; we return count best-effort like CI
|
||||
// insert returns bool; we return count best-effort like legacy
|
||||
DB::table((new static)->getTable())->insert($rows);
|
||||
return count($rows);
|
||||
} catch (QueryException $e) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class CalendarEvent extends BaseModel
|
||||
{
|
||||
protected $table = 'calendar_events';
|
||||
|
||||
// ✅ CI uses created_at / updated_at
|
||||
// ✅ legacy uses created_at / updated_at
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -42,7 +42,7 @@ class CalendarEvent extends BaseModel
|
||||
private static ?bool $hasEventTypeColumn = null;
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function getEvents()
|
||||
@@ -96,7 +96,7 @@ class CalendarEvent extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* Helpers (ported from CI)
|
||||
* Helpers (ported from legacy)
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CiDatabase
|
||||
{
|
||||
protected static ?self $instance = null;
|
||||
|
||||
protected Connection $connection;
|
||||
protected int $lastAffectedRows = 0;
|
||||
|
||||
public static function instance(): self
|
||||
{
|
||||
return static::$instance ??= new static();
|
||||
}
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->connection = DB::connection();
|
||||
}
|
||||
|
||||
public function table(string $table): CiQueryBuilder
|
||||
{
|
||||
$normalized = $this->normalizeTableName($table);
|
||||
return new CiQueryBuilder($this->connection->table($normalized));
|
||||
}
|
||||
|
||||
public function query(string $sql, array $params = []): CiQueryResult
|
||||
{
|
||||
$trimmed = ltrim($sql);
|
||||
if ($trimmed === '') {
|
||||
return new CiQueryResult([]);
|
||||
}
|
||||
|
||||
$first = strtolower(strtok($trimmed, " \t\n\r\0\x0B") ?: '');
|
||||
|
||||
if ($first === 'select') {
|
||||
$rows = $this->connection->select($sql, $params);
|
||||
$this->lastAffectedRows = 0;
|
||||
return new CiQueryResult($rows);
|
||||
}
|
||||
|
||||
$affected = $this->connection->affectingStatement($sql, $params);
|
||||
$this->lastAffectedRows = $affected;
|
||||
|
||||
return new CiQueryResult([]);
|
||||
}
|
||||
|
||||
public function escape($value): string
|
||||
{
|
||||
return $this->connection->getPdo()->quote($value);
|
||||
}
|
||||
|
||||
public function affectedRows(): int
|
||||
{
|
||||
return $this->lastAffectedRows;
|
||||
}
|
||||
|
||||
public function getFieldNames(string $table): array
|
||||
{
|
||||
return $this->connection->getSchemaBuilder()->getColumnListing($table);
|
||||
}
|
||||
|
||||
protected function normalizeTableName(string $table): string
|
||||
{
|
||||
$normalized = trim($table);
|
||||
|
||||
if (stripos($normalized, ' as ') !== false) {
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
if (strpos($normalized, ' ') !== false) {
|
||||
[$name, $alias] = preg_split('/\s+/', $normalized, 2);
|
||||
return "{$name} as {$alias}";
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class CiModelBuilder extends Builder
|
||||
{
|
||||
protected array $setData = [];
|
||||
|
||||
public function get($columns = ['*'])
|
||||
{
|
||||
return new CiQueryResult(parent::get($columns));
|
||||
}
|
||||
|
||||
public function first($columns = ['*'])
|
||||
{
|
||||
$model = parent::first($columns);
|
||||
return $model;
|
||||
}
|
||||
|
||||
public function findAll(int $limit = 0, int $offset = 0)
|
||||
{
|
||||
if ($limit > 0) {
|
||||
$this->limit($limit);
|
||||
}
|
||||
|
||||
if ($offset > 0) {
|
||||
$this->offset($offset);
|
||||
}
|
||||
|
||||
return $this->getResultArray();
|
||||
}
|
||||
|
||||
public function getResultArray(): array
|
||||
{
|
||||
return $this->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getRowArray(): ?array
|
||||
{
|
||||
return $this->get()->getRowArray();
|
||||
}
|
||||
|
||||
public function getRow(?string $column = null)
|
||||
{
|
||||
return $this->get()->getRow($column);
|
||||
}
|
||||
|
||||
public function countAllResults(): int
|
||||
{
|
||||
return $this->count();
|
||||
}
|
||||
|
||||
public function like(string $column, $match, string $side = 'both')
|
||||
{
|
||||
$pattern = $this->wrapLike($match, $side);
|
||||
$this->query->where($column, 'like', $pattern);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set($key, $value = null, bool $escape = true)
|
||||
{
|
||||
if (is_array($key)) {
|
||||
$this->setData = array_merge($this->setData, $key);
|
||||
} else {
|
||||
$this->setData[$key] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function update(array $values = [])
|
||||
{
|
||||
$data = $values ?: $this->setData;
|
||||
$this->setData = [];
|
||||
|
||||
return parent::update($data);
|
||||
}
|
||||
|
||||
public function where($column, $operator = null, $value = null, $boolean = 'and')
|
||||
{
|
||||
if ($operator !== null && $value === null && preg_match('/^(.*)\\s(>=|<=|<>|!=|>|<)$/', $column, $matches)) {
|
||||
return parent::where(trim($matches[1]), $matches[2], $operator, $boolean);
|
||||
}
|
||||
|
||||
return parent::where($column, $operator, $value, $boolean);
|
||||
}
|
||||
|
||||
protected function wrapLike($match, string $side): string
|
||||
{
|
||||
$pattern = "%{$match}%";
|
||||
|
||||
switch (strtolower($side)) {
|
||||
case 'before':
|
||||
$pattern = "%{$match}";
|
||||
break;
|
||||
case 'after':
|
||||
$pattern = "{$match}%";
|
||||
break;
|
||||
}
|
||||
|
||||
return $pattern;
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Query\Builder as QueryBuilder;
|
||||
|
||||
class CiQueryBuilder
|
||||
{
|
||||
protected QueryBuilder $builder;
|
||||
protected array $setData = [];
|
||||
|
||||
protected array $tableMethods = [
|
||||
'join',
|
||||
'leftJoin',
|
||||
'rightJoin',
|
||||
'crossJoin',
|
||||
'from',
|
||||
'table',
|
||||
'joinWhere',
|
||||
'leftJoinWhere',
|
||||
];
|
||||
|
||||
public function __construct(QueryBuilder $builder)
|
||||
{
|
||||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
$arguments = $this->normalizeTableArgument($method, $arguments);
|
||||
$result = $this->builder->$method(...$arguments);
|
||||
|
||||
if ($result instanceof QueryBuilder) {
|
||||
$this->builder = $result;
|
||||
return $this;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function where($column, $operator = null, $value = null, $boolean = 'and')
|
||||
{
|
||||
if ($operator !== null && $value === null && preg_match('/^(.*)\s(>=|<=|<>|!=|>|<)$/', $column, $matches)) {
|
||||
return $this->where(trim($matches[1]), $matches[2], $operator, $boolean);
|
||||
}
|
||||
|
||||
$this->builder = $this->builder->where($column, $operator, $value, $boolean);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function like($column, $match, string $side = 'both')
|
||||
{
|
||||
$pattern = $this->wrapLike($match, $side);
|
||||
$this->builder = $this->builder->where($column, 'like', $pattern);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function set($key, $value = null, bool $escape = true)
|
||||
{
|
||||
if (is_array($key)) {
|
||||
$this->setData = array_merge($this->setData, $key);
|
||||
} else {
|
||||
$this->setData[$key] = $value;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function update($values = [])
|
||||
{
|
||||
$data = $values ?: $this->setData;
|
||||
$this->setData = [];
|
||||
return $this->builder->update($data);
|
||||
}
|
||||
|
||||
public function findAll(int $limit = 0, int $offset = 0)
|
||||
{
|
||||
if ($limit > 0) {
|
||||
$this->builder = $this->builder->limit($limit);
|
||||
}
|
||||
|
||||
if ($offset > 0) {
|
||||
$this->builder = $this->builder->offset($offset);
|
||||
}
|
||||
|
||||
return $this->getResultArray();
|
||||
}
|
||||
|
||||
public function get($columns = ['*'])
|
||||
{
|
||||
$collection = $this->builder->get($columns);
|
||||
return new CiQueryResult($collection);
|
||||
}
|
||||
|
||||
public function getResultArray(): array
|
||||
{
|
||||
return $this->get()->getResultArray();
|
||||
}
|
||||
|
||||
public function getRowArray(): ?array
|
||||
{
|
||||
return $this->get()->getRowArray();
|
||||
}
|
||||
|
||||
public function getRow(?string $column = null)
|
||||
{
|
||||
return $this->get()->getRow($column);
|
||||
}
|
||||
|
||||
public function countAllResults(): int
|
||||
{
|
||||
return $this->builder->count();
|
||||
}
|
||||
|
||||
protected function wrapLike($match, string $side): string
|
||||
{
|
||||
$pattern = "%{$match}%";
|
||||
|
||||
switch (strtolower($side)) {
|
||||
case 'before':
|
||||
return "%{$match}";
|
||||
case 'after':
|
||||
return "{$match}%";
|
||||
default:
|
||||
return $pattern;
|
||||
}
|
||||
}
|
||||
|
||||
protected function normalizeTableArgument(string $method, array $arguments): array
|
||||
{
|
||||
if (in_array($method, $this->tableMethods, true) && isset($arguments[0]) && is_string($arguments[0])) {
|
||||
$arguments[0] = $this->normalizeTableName($arguments[0]);
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
protected function normalizeTableName(string $table): string
|
||||
{
|
||||
$normalized = trim($table);
|
||||
|
||||
if (stripos($normalized, ' as ') !== false) {
|
||||
return $normalized;
|
||||
}
|
||||
|
||||
if (strpos($normalized, ' ') !== false) {
|
||||
[$name, $alias] = preg_split('/\s+/', $normalized, 2);
|
||||
return "{$name} as {$alias}";
|
||||
}
|
||||
|
||||
return $normalized;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
class CiQueryResult extends Collection
|
||||
{
|
||||
public function __construct($items = [])
|
||||
{
|
||||
if ($items instanceof Collection) {
|
||||
$items = $items->all();
|
||||
}
|
||||
|
||||
parent::__construct(array_map([$this, 'castRow'], (array) $items));
|
||||
}
|
||||
|
||||
protected function castRow($row): array
|
||||
{
|
||||
if ($row instanceof Model) {
|
||||
return $row->toArray();
|
||||
}
|
||||
|
||||
if (is_object($row)) {
|
||||
return (array) $row;
|
||||
}
|
||||
|
||||
return (array) $row;
|
||||
}
|
||||
|
||||
public function getResultArray(): array
|
||||
{
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
public function getRowArray(): ?array
|
||||
{
|
||||
$first = $this->first();
|
||||
return $first ? (array) $first : null;
|
||||
}
|
||||
|
||||
public function getRow(?string $column = null)
|
||||
{
|
||||
$row = $this->getRowArray();
|
||||
if ($row === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($column === null) {
|
||||
return $row;
|
||||
}
|
||||
|
||||
return $row[$column] ?? null;
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ class ClassPrepAdjustment extends BaseModel
|
||||
{
|
||||
protected $table = 'class_prep_adjustments';
|
||||
|
||||
// CI model didn't use timestamps; keep off unless your table has updated_at/created_at auto-managed.
|
||||
// legacy model didn't use timestamps; keep off unless your table has updated_at/created_at auto-managed.
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class ClassPreparationLog extends BaseModel
|
||||
{
|
||||
protected $table = 'class_preparation_log';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -10,7 +10,7 @@ class ClassProgressAttachment extends BaseModel
|
||||
use HasFactory;
|
||||
protected $table = 'class_progress_attachments';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -10,7 +10,7 @@ class ClassProgressReport extends BaseModel
|
||||
use HasFactory;
|
||||
protected $table = 'class_progress_reports';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -9,10 +9,10 @@ use Illuminate\Support\Facades\DB;
|
||||
class ClassSection extends BaseModel
|
||||
{
|
||||
use HasFactory;
|
||||
// CI table name is "classSection"
|
||||
// legacy table name is "classSection"
|
||||
protected $table = 'classSection';
|
||||
|
||||
// ✅ CI: useTimestamps = true
|
||||
// ✅ legacy: useTimestamps = true
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -48,11 +48,11 @@ class ClassSection extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
* Get class sections with class name (like CI join result).
|
||||
* Get class sections with class name (like legacy join result).
|
||||
* Returns array of rows: class_section_id, class_section_name, class_name
|
||||
*/
|
||||
public static function getClassSections(): array
|
||||
|
||||
@@ -8,7 +8,7 @@ class CommunicationLog extends BaseModel
|
||||
{
|
||||
protected $table = 'communication_logs';
|
||||
|
||||
// CI model didn't enable timestamps; keep off unless your table has created_at/updated_at.
|
||||
// legacy model didn't enable timestamps; keep off unless your table has created_at/updated_at.
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -9,10 +9,10 @@ class Competition extends BaseModel
|
||||
{
|
||||
protected $table = 'competitions';
|
||||
|
||||
// ✅ CI: useSoftDeletes = true
|
||||
// ✅ legacy: useSoftDeletes = true
|
||||
use SoftDeletes;
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at) + deleted_at for soft deletes
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at) + deleted_at for soft deletes
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class CompetitionClassWinner extends BaseModel
|
||||
{
|
||||
protected $table = 'competition_class_winners';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class CompetitionScore extends BaseModel
|
||||
{
|
||||
protected $table = 'competition_scores';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class CompetitionWinner extends BaseModel
|
||||
{
|
||||
protected $table = 'competition_winners';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -18,7 +18,7 @@ class Configuration extends BaseModel
|
||||
];
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ class Configuration extends BaseModel
|
||||
* Backward-compatible helper (keeps your "semester" special-case).
|
||||
*
|
||||
* NOTE: In Laravel it’s better to call SemesterRangeService directly from services/controllers,
|
||||
* but this keeps behavior consistent with the CI model.
|
||||
* but this keeps behavior consistent with the legacy model.
|
||||
*/
|
||||
public static function getConfig(string $key): ?string
|
||||
{
|
||||
@@ -103,7 +103,7 @@ class Configuration extends BaseModel
|
||||
if ($key === 'semester') {
|
||||
try {
|
||||
// If you have this service in Laravel, inject/resolve it from container.
|
||||
// This call assumes the service constructor can accept Configuration model (like CI did).
|
||||
// This call assumes the service constructor can accept Configuration model (like legacy did).
|
||||
$semester = app(\App\Services\SemesterRangeService::class)->getSemesterForDate();
|
||||
if (is_string($semester) && $semester !== '') {
|
||||
return $semester;
|
||||
|
||||
@@ -8,7 +8,7 @@ class ContactUs extends BaseModel
|
||||
{
|
||||
protected $table = 'contactus';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -39,7 +39,7 @@ class ContactUs extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ class CurrentFlag extends BaseModel
|
||||
{
|
||||
protected $table = 'current_flag';
|
||||
|
||||
// CI model didn't specify timestamps. Since the table has created_at/updated_at columns,
|
||||
// legacy model didn't specify timestamps. Since the table has created_at/updated_at columns,
|
||||
// you can enable auto-management. If your table does NOT actually have them, set false.
|
||||
public $timestamps = true;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class DiscountUsage extends BaseModel
|
||||
{
|
||||
protected $table = 'discount_usages';
|
||||
|
||||
// ✅ CI: timestamps enabled (created_at / updated_at)
|
||||
// ✅ legacy: timestamps enabled (created_at / updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -44,7 +44,7 @@ class DiscountUsage extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getTotalDiscountByParentIdAndSchoolYear()
|
||||
* Equivalent of legacy getTotalDiscountByParentIdAndSchoolYear()
|
||||
*/
|
||||
public static function getTotalDiscountByParentIdAndSchoolYear(int $parentId, string $schoolYear): float
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ class DiscountVoucher extends BaseModel
|
||||
{
|
||||
protected $table = 'discount_vouchers';
|
||||
|
||||
// ✅ CI manages created_at / updated_at
|
||||
// ✅ legacy manages created_at / updated_at
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -39,7 +39,7 @@ class DiscountVoucher extends BaseModel
|
||||
];
|
||||
|
||||
/* =========================
|
||||
* Model hooks (CI beforeInsert/beforeUpdate equivalents)
|
||||
* Model hooks (legacy beforeInsert/beforeUpdate equivalents)
|
||||
* ========================= */
|
||||
|
||||
protected static function booted(): void
|
||||
@@ -95,7 +95,7 @@ class DiscountVoucher extends BaseModel
|
||||
$until = Carbon::parse($this->valid_until)->toDateString();
|
||||
if ($from > $until) {
|
||||
// In Laravel, prefer validating in FormRequest.
|
||||
// This keeps your CI behavior by failing the save.
|
||||
// This keeps your legacy behavior by failing the save.
|
||||
throw new \InvalidArgumentException('Valid Until must be the same as or after Valid From.');
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ class DiscountVoucher extends BaseModel
|
||||
/**
|
||||
* Find a valid voucher for a student (not expired, active, under max uses, and not used by the student).
|
||||
*
|
||||
* NOTE: Your CI joins discount_usages on u.student_id. That requires discount_usages.student_id to exist.
|
||||
* NOTE: Your legacy joins discount_usages on u.student_id. That requires discount_usages.student_id to exist.
|
||||
* If your discount_usages table does NOT have student_id (some of your other code uses parent_id),
|
||||
* switch the filter to parent_id instead.
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ class EarlyDismissalSignature extends BaseModel
|
||||
{
|
||||
protected $table = 'early_dismissal_signatures';
|
||||
|
||||
// ✅ CI: timestamps enabled (created_at/updated_at)
|
||||
// ✅ legacy: timestamps enabled (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -23,7 +23,7 @@ class EarlyDismissalSignature extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
// report_date is stored as Y-m-d in CI validation; keep as date
|
||||
// report_date is stored as Y-m-d in legacy validation; keep as date
|
||||
'report_date' => 'date',
|
||||
|
||||
'file_size' => 'integer',
|
||||
|
||||
@@ -8,7 +8,7 @@ class EmailTemplate extends BaseModel
|
||||
{
|
||||
protected $table = 'email_templates';
|
||||
|
||||
// CI model didn't specify timestamps; keep off unless your table has created_at/updated_at.
|
||||
// legacy model didn't specify timestamps; keep off unless your table has created_at/updated_at.
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -40,7 +40,7 @@ class EmailTemplate extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getActiveTemplates():
|
||||
* Equivalent of legacy getActiveTemplates():
|
||||
* is_active=1, orderBy template_key ASC
|
||||
*/
|
||||
public static function getActiveTemplates()
|
||||
@@ -52,7 +52,7 @@ class EmailTemplate extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI findByKey():
|
||||
* Equivalent of legacy findByKey():
|
||||
* template_key = $key AND is_active=1
|
||||
*/
|
||||
public static function findByKey(string $key): ?self
|
||||
|
||||
@@ -8,7 +8,7 @@ class EmergencyContact extends BaseModel
|
||||
{
|
||||
protected $table = 'emergency_contacts';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -46,7 +46,7 @@ class EmergencyContact extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function getEmergencyContactsByStudentId(int $studentId)
|
||||
@@ -64,7 +64,7 @@ class EmergencyContact extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Your CI logic: (student_id = $studentId) OR (parent_id = $studentId)
|
||||
* Your legacy logic: (student_id = $studentId) OR (parent_id = $studentId)
|
||||
* Keeping it exactly as-is, even though the 2nd condition looks unusual.
|
||||
*/
|
||||
public static function getAllEmergencyContacts(int $studentId)
|
||||
|
||||
@@ -9,7 +9,7 @@ class Enrollment extends BaseModel
|
||||
{
|
||||
protected $table = 'enrollments';
|
||||
|
||||
// ✅ CI: useTimestamps = true
|
||||
// ✅ legacy: useTimestamps = true
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -55,7 +55,7 @@ class Enrollment extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,7 @@ class Event extends BaseModel
|
||||
{
|
||||
protected $table = 'events';
|
||||
|
||||
// ✅ CI: timestamps enabled (created_at/updated_at)
|
||||
// ✅ legacy: timestamps enabled (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -43,7 +43,7 @@ class Event extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ class EventCharges extends BaseModel
|
||||
{
|
||||
protected $table = 'event_charges';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -66,7 +66,7 @@ class EventCharges extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getChargesWithEventInfo()
|
||||
* Equivalent of legacy getChargesWithEventInfo()
|
||||
* Returns rows with: event_charges.*, events.event_name, events.amount
|
||||
*/
|
||||
public static function getChargesWithEventInfo(?int $parentId = null, ?string $schoolYear = null, ?string $semester = null): array
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class Exam extends BaseModel
|
||||
protected $table = 'exams';
|
||||
|
||||
/**
|
||||
* Your CI model only uses created_at (updatedField = '').
|
||||
* Your legacy model only uses created_at (updatedField = '').
|
||||
* In Laravel, easiest is to disable timestamps and manage created_at yourself OR
|
||||
* enable timestamps but disable UPDATED_AT.
|
||||
*
|
||||
|
||||
@@ -8,7 +8,7 @@ class ExamDraft extends BaseModel
|
||||
{
|
||||
protected $table = 'exam_drafts';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -55,7 +55,7 @@ class ExamDraft extends BaseModel
|
||||
];
|
||||
|
||||
/**
|
||||
* CI had updateOnlyChanged=false (force updates even if nothing changed).
|
||||
* legacy had updateOnlyChanged=false (force updates even if nothing changed).
|
||||
* In Laravel, you can force a save by calling:
|
||||
* $model->touch(); // updates updated_at only
|
||||
* or
|
||||
|
||||
@@ -9,7 +9,7 @@ class Expense extends BaseModel
|
||||
{
|
||||
protected $table = 'expenses';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class Family extends BaseModel
|
||||
{
|
||||
protected $table = 'families';
|
||||
|
||||
// CI model didn't specify timestamps
|
||||
// legacy model didn't specify timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class FamilyCommPref extends BaseModel
|
||||
{
|
||||
protected $table = 'family_comm_prefs';
|
||||
|
||||
// CI model didn't specify timestamps
|
||||
// legacy model didn't specify timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class FamilyGuardian extends BaseModel
|
||||
{
|
||||
protected $table = 'family_guardians';
|
||||
|
||||
// CI model didn't specify timestamps
|
||||
// legacy model didn't specify timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -9,7 +9,7 @@ class FamilyStudent extends BaseModel
|
||||
{
|
||||
protected $table = 'family_students';
|
||||
|
||||
// CI model didn't specify timestamps
|
||||
// legacy model didn't specify timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -37,7 +37,7 @@ class FamilyStudent extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Laravel equivalent of CI getFamiliesForStudent().
|
||||
* Laravel equivalent of legacy getFamiliesForStudent().
|
||||
* Returns array rows: families.* + is_primary_home
|
||||
*/
|
||||
public static function getFamiliesForStudent(int $studentId): array
|
||||
|
||||
@@ -9,7 +9,7 @@ class FinalExam extends BaseModel
|
||||
protected $table = 'final_exam';
|
||||
|
||||
/**
|
||||
* CI: useTimestamps = false (even though table has created_at/updated_at fields).
|
||||
* legacy: useTimestamps = false (even though table has created_at/updated_at fields).
|
||||
* So we keep timestamps OFF and you can set created_at/updated_at manually if needed.
|
||||
*/
|
||||
public $timestamps = false;
|
||||
@@ -52,7 +52,7 @@ class FinalExam extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getFinalExamScore()
|
||||
* Equivalent of legacy getFinalExamScore()
|
||||
*/
|
||||
public static function getFinalExamScore(
|
||||
int $studentId,
|
||||
|
||||
@@ -8,7 +8,7 @@ class FinalScore extends BaseModel
|
||||
{
|
||||
protected $table = 'final_score';
|
||||
|
||||
// CI model didn't specify timestamps behavior; table includes created_at/updated_at.
|
||||
// legacy model didn't specify timestamps behavior; table includes created_at/updated_at.
|
||||
// If you want Laravel to auto-manage them, keep true (recommended).
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -51,7 +51,7 @@ class FinalScore extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getFinalExamScore()
|
||||
* Equivalent of legacy getFinalExamScore()
|
||||
*/
|
||||
public static function getFinalExamScore(int $studentId, string $semester, string $schoolYear)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ class GradingLock extends BaseModel
|
||||
{
|
||||
protected $table = 'grading_locks';
|
||||
|
||||
// ✅ CI: useTimestamps = true
|
||||
// ✅ legacy: useTimestamps = true
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -41,7 +41,7 @@ class GradingLock extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getLock()
|
||||
* Equivalent of legacy getLock()
|
||||
*/
|
||||
public static function getLock(int $classSectionId, string $semester, string $schoolYear): ?self
|
||||
{
|
||||
@@ -58,7 +58,7 @@ class GradingLock extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI isLocked()
|
||||
* Equivalent of legacy isLocked()
|
||||
*/
|
||||
public static function isLocked(int $classSectionId, string $semester, string $schoolYear): bool
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ class Homework extends BaseModel
|
||||
protected $table = 'homework';
|
||||
|
||||
/**
|
||||
* CI: useTimestamps = false (even though created_at/updated_at columns exist).
|
||||
* legacy: useTimestamps = false (even though created_at/updated_at columns exist).
|
||||
* Keep it OFF to match behavior. If you want Laravel to auto-manage, tell me.
|
||||
*/
|
||||
public $timestamps = false;
|
||||
@@ -55,7 +55,7 @@ class Homework extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Laravel equivalent of CI getAverageHomeworkScore()
|
||||
* Laravel equivalent of legacy getAverageHomeworkScore()
|
||||
* Computes average based only on non-blank numeric scores.
|
||||
*/
|
||||
public static function getAverageHomeworkScore(
|
||||
|
||||
@@ -8,7 +8,7 @@ class InventoryCategory extends BaseModel
|
||||
{
|
||||
protected $table = 'inventory_categories';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -27,7 +27,7 @@ class InventoryCategory extends BaseModel
|
||||
];
|
||||
|
||||
/**
|
||||
* Equivalent of CI optionsForType()
|
||||
* Equivalent of legacy optionsForType()
|
||||
* Returns array rows: id, name, description, grade_min, grade_max
|
||||
*/
|
||||
public static function optionsForType(string $type): array
|
||||
|
||||
@@ -8,7 +8,7 @@ class InventoryItem extends BaseModel
|
||||
{
|
||||
protected $table = 'inventory_items';
|
||||
|
||||
// ✅ CI: useTimestamps = true
|
||||
// ✅ legacy: useTimestamps = true
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class InventoryMovement extends BaseModel
|
||||
{
|
||||
protected $table = 'inventory_movements';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -11,7 +11,7 @@ class Invoice extends BaseModel
|
||||
protected $table = 'invoices';
|
||||
|
||||
/**
|
||||
* CI: useTimestamps = false because DB defaults/triggers manage created_at/updated_at.
|
||||
* legacy: useTimestamps = false because DB defaults/triggers manage created_at/updated_at.
|
||||
* In Laravel, keep timestamps OFF and let DB handle them.
|
||||
*/
|
||||
public $timestamps = false;
|
||||
@@ -67,7 +67,7 @@ class Invoice extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI beforeInsert/beforeUpdate equivalents (normalize to UTC)
|
||||
* legacy beforeInsert/beforeUpdate equivalents (normalize to UTC)
|
||||
* ========================= */
|
||||
|
||||
protected static function booted(): void
|
||||
@@ -135,7 +135,7 @@ class Invoice extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* Queries (ported from CI)
|
||||
* Queries (ported from legacy)
|
||||
* ========================= */
|
||||
|
||||
public static function getInvoicesByUserId(int $userId, ?string $schoolYear = null): array
|
||||
|
||||
@@ -8,7 +8,7 @@ class InvoiceEvent extends BaseModel
|
||||
{
|
||||
protected $table = 'invoice_event';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class InvoiceStudentList extends BaseModel
|
||||
{
|
||||
protected $table = 'invoice_students_list';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class IpAttempt extends BaseModel
|
||||
{
|
||||
protected $table = 'ip_attempts';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -27,7 +27,7 @@ class IpAttempt extends BaseModel
|
||||
];
|
||||
|
||||
/**
|
||||
* Equivalent of CI getAttemptByIp()
|
||||
* Equivalent of legacy getAttemptByIp()
|
||||
*/
|
||||
public static function getAttemptByIp(string $ip): ?self
|
||||
{
|
||||
@@ -37,7 +37,7 @@ class IpAttempt extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI updateIpAttempt()
|
||||
* Equivalent of legacy updateIpAttempt()
|
||||
*/
|
||||
public static function updateIpAttempt(string $ip, array $data): bool
|
||||
{
|
||||
@@ -47,7 +47,7 @@ class IpAttempt extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI insertIpAttempt()
|
||||
* Equivalent of legacy insertIpAttempt()
|
||||
* Returns inserted id.
|
||||
*/
|
||||
public static function insertIpAttempt(array $data): int
|
||||
|
||||
@@ -10,7 +10,7 @@ class LateSlipLog extends BaseModel
|
||||
{
|
||||
protected $table = 'late_slip_logs';
|
||||
|
||||
// CI: useTimestamps = false (printed_at is controlled explicitly)
|
||||
// legacy: useTimestamps = false (printed_at is controlled explicitly)
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class LoginActivity extends BaseModel
|
||||
{
|
||||
protected $table = 'login_activity';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -37,7 +37,7 @@ class LoginActivity extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getLastActivities()
|
||||
* Equivalent of legacy getLastActivities()
|
||||
*/
|
||||
public static function getLastActivities(int $limit = 4)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ class ManualPayment extends BaseModel
|
||||
{
|
||||
protected $table = 'manual_payments';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class Message extends BaseModel
|
||||
{
|
||||
protected $table = 'messages';
|
||||
|
||||
// CI: useTimestamps = false (manual date fields)
|
||||
// legacy: useTimestamps = false (manual date fields)
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -49,7 +49,7 @@ class Message extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function getUnreadMessages(int $recipientId)
|
||||
|
||||
@@ -9,7 +9,7 @@ class MidtermExam extends BaseModel
|
||||
protected $table = 'midterm_exam';
|
||||
|
||||
/**
|
||||
* CI: useTimestamps = false (even though created_at/updated_at columns exist).
|
||||
* legacy: useTimestamps = false (even though created_at/updated_at columns exist).
|
||||
* Keep it OFF to match behavior (you can still store created_at/updated_at manually).
|
||||
*/
|
||||
public $timestamps = false;
|
||||
@@ -52,7 +52,7 @@ class MidtermExam extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getMidtermExamScore()
|
||||
* Equivalent of legacy getMidtermExamScore()
|
||||
*/
|
||||
public static function getMidtermExamScore(
|
||||
int $studentId,
|
||||
|
||||
@@ -9,7 +9,7 @@ class MissingScoreOverride extends BaseModel
|
||||
{
|
||||
protected $table = 'missing_score_overrides';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -34,7 +34,7 @@ class MissingScoreOverride extends BaseModel
|
||||
];
|
||||
|
||||
/**
|
||||
* Equivalent of CI getOverridesMap()
|
||||
* Equivalent of legacy getOverridesMap()
|
||||
* Returns: [student_id => [item_index => true]]
|
||||
*/
|
||||
public static function getOverridesMap(int $classSectionId, string $semester, string $schoolYear, string $itemType): array
|
||||
@@ -65,7 +65,7 @@ class MissingScoreOverride extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI replaceOverrides()
|
||||
* Equivalent of legacy replaceOverrides()
|
||||
* Deletes matching overrides then inserts checked items.
|
||||
*/
|
||||
public static function replaceOverrides(
|
||||
@@ -109,7 +109,7 @@ class MissingScoreOverride extends BaseModel
|
||||
if (!empty($itemIndexes)) {
|
||||
$q->whereIn('item_index', array_map('intval', $itemIndexes));
|
||||
} else {
|
||||
// CI behavior: if itemIndexes is provided but empty, do nothing.
|
||||
// legacy behavior: if itemIndexes is provided but empty, do nothing.
|
||||
return;
|
||||
}
|
||||
} elseif ($nullIndex) {
|
||||
|
||||
@@ -9,7 +9,7 @@ class NavItem extends BaseModel
|
||||
{
|
||||
protected $table = 'nav_items';
|
||||
|
||||
// ✅ CI: timestamps + soft deletes
|
||||
// ✅ legacy: timestamps + soft deletes
|
||||
use SoftDeletes;
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -41,8 +41,8 @@ class NavItem extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getChildrenOf()
|
||||
* NOTE: CI code uses where('parent_id', ...) but allowedFields has menu_parent_id.
|
||||
* Equivalent of legacy getChildrenOf()
|
||||
* NOTE: legacy code uses where('parent_id', ...) but allowedFields has menu_parent_id.
|
||||
* This Laravel version uses menu_parent_id (likely correct).
|
||||
*/
|
||||
public static function getChildrenOf(int $parentId): array
|
||||
|
||||
@@ -9,7 +9,7 @@ class Notification extends BaseModel
|
||||
{
|
||||
protected $table = 'notifications';
|
||||
|
||||
// ✅ CI: soft deletes + timestamps
|
||||
// ✅ legacy: soft deletes + timestamps
|
||||
use SoftDeletes;
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -35,7 +35,7 @@ class Notification extends BaseModel
|
||||
];
|
||||
|
||||
/**
|
||||
* Equivalent of CI getActiveNotifications()
|
||||
* Equivalent of legacy getActiveNotifications()
|
||||
* Active = scheduled_at <= now AND (expires_at is null OR expires_at > now)
|
||||
*/
|
||||
public static function getActiveNotifications(?string $targetGroup = null): array
|
||||
@@ -58,7 +58,7 @@ class Notification extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getDeletedNotifications()
|
||||
* Equivalent of legacy getDeletedNotifications()
|
||||
*/
|
||||
public static function getDeletedNotifications(): array
|
||||
{
|
||||
@@ -69,7 +69,7 @@ class Notification extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getAllNotificationsWithDeleted()
|
||||
* Equivalent of legacy getAllNotificationsWithDeleted()
|
||||
*/
|
||||
public static function getAllNotificationsWithDeleted(): array
|
||||
{
|
||||
@@ -80,7 +80,7 @@ class Notification extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI restoreNotification()
|
||||
* Equivalent of legacy restoreNotification()
|
||||
*/
|
||||
public static function restoreNotification(int $id): bool
|
||||
{
|
||||
@@ -90,7 +90,7 @@ class Notification extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI deleteExpiredNotifications()
|
||||
* Equivalent of legacy deleteExpiredNotifications()
|
||||
* Soft-deletes rows with expires_at < now (and expires_at not null)
|
||||
*/
|
||||
public static function deleteExpiredNotifications(): int
|
||||
|
||||
@@ -9,7 +9,7 @@ class ParentAttendanceReport extends BaseModel
|
||||
{
|
||||
protected $table = 'parent_attendance_reports';
|
||||
|
||||
// ✅ CI: useTimestamps = true
|
||||
// ✅ legacy: useTimestamps = true
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -51,7 +51,7 @@ class ParentAttendanceReport extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Laravel equivalent of CI listForDateRange()
|
||||
* Laravel equivalent of legacy listForDateRange()
|
||||
* Returns array rows with:
|
||||
* parent_attendance_reports.* + students firstname/lastname + classSection class_section_name
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ class ParentMeetingSchedule extends BaseModel
|
||||
{
|
||||
protected $table = 'parent_meeting_schedules';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class ParentModel extends BaseModel
|
||||
{
|
||||
protected $table = 'parents';
|
||||
|
||||
// CI model didn't specify timestamps
|
||||
// legacy model didn't specify timestamps
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class ParentNotification extends BaseModel
|
||||
{
|
||||
protected $table = 'parent_notifications';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -26,7 +26,7 @@ class ParentNotification extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
'student_id' => 'integer',
|
||||
// incident_date is stored as Y-m-d in CI usage
|
||||
// incident_date is stored as Y-m-d in legacy usage
|
||||
'incident_date' => 'date',
|
||||
];
|
||||
|
||||
@@ -37,7 +37,7 @@ class ParentNotification extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI hasSent()
|
||||
* Equivalent of legacy hasSent()
|
||||
*/
|
||||
public static function hasSent(
|
||||
int $studentId,
|
||||
|
||||
@@ -9,7 +9,7 @@ class Participation extends BaseModel
|
||||
protected $table = 'participation';
|
||||
|
||||
/**
|
||||
* CI: useTimestamps = false (even though created_at/updated_at columns exist).
|
||||
* legacy: useTimestamps = false (even though created_at/updated_at columns exist).
|
||||
* Keep OFF to match behavior (you can still set created_at/updated_at manually).
|
||||
*/
|
||||
public $timestamps = false;
|
||||
@@ -52,7 +52,7 @@ class Participation extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI getParticipationScore()
|
||||
* Equivalent of legacy getParticipationScore()
|
||||
* Returns null if missing/blank/non-numeric.
|
||||
*/
|
||||
public static function getParticipationScore(
|
||||
|
||||
@@ -9,7 +9,7 @@ class PasswordReset extends BaseModel
|
||||
protected $table = 'password_resets';
|
||||
|
||||
/**
|
||||
* In CI you used:
|
||||
* In legacy you used:
|
||||
* - createdField = created_at
|
||||
* - updatedField = expires_at (non-standard)
|
||||
*
|
||||
|
||||
@@ -8,7 +8,7 @@ class PasswordResetRequest extends BaseModel
|
||||
{
|
||||
protected $table = 'password_reset_requests';
|
||||
|
||||
// CI: timestamps off
|
||||
// legacy: timestamps off
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -9,7 +9,7 @@ class PayPalPayment extends BaseModel
|
||||
protected $table = 'paypal_payments';
|
||||
|
||||
/**
|
||||
* CI: created_at is managed, updated_at is NOT used.
|
||||
* legacy: created_at is managed, updated_at is NOT used.
|
||||
* In Laravel: enable timestamps but disable UPDATED_AT.
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -10,7 +10,7 @@ class Payment extends BaseModel
|
||||
protected $table = 'payments';
|
||||
|
||||
/**
|
||||
* CI: useTimestamps = false because DB handles created_at/updated_at (defaults/triggers).
|
||||
* legacy: useTimestamps = false because DB handles created_at/updated_at (defaults/triggers).
|
||||
* Keep OFF in Laravel too.
|
||||
*/
|
||||
public $timestamps = false;
|
||||
@@ -58,7 +58,7 @@ class Payment extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function getPaymentsByParentId(int $parentId): array
|
||||
@@ -135,7 +135,7 @@ class Payment extends BaseModel
|
||||
|
||||
/**
|
||||
* Get latest payment (date/amount/status) per invoice for given invoice IDs.
|
||||
* Matches your CI logic: statuses in ['Full','Paid','Partially Paid'].
|
||||
* Matches your legacy logic: statuses in ['Full','Paid','Partially Paid'].
|
||||
*/
|
||||
public static function getPaymentsByInvoice($invoiceIds): array
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ class PaymentError extends BaseModel
|
||||
{
|
||||
protected $table = 'payment_error';
|
||||
|
||||
// CI: useTimestamps = false (logged_at managed manually)
|
||||
// legacy: useTimestamps = false (logged_at managed manually)
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class PaymentNotificationLog extends BaseModel
|
||||
{
|
||||
protected $table = 'payment_notification_logs';
|
||||
|
||||
// CI: useTimestamps = false (created_at / sent_at are managed manually)
|
||||
// legacy: useTimestamps = false (created_at / sent_at are managed manually)
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -53,7 +53,7 @@ class PaymentNotificationLog extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI existsForPeriod()
|
||||
* Equivalent of legacy existsForPeriod()
|
||||
*/
|
||||
public static function existsForPeriod(int $parentId, int $year, int $month, string $type): bool
|
||||
{
|
||||
@@ -66,7 +66,7 @@ class PaymentNotificationLog extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent of CI listLogs()
|
||||
* Equivalent of legacy listLogs()
|
||||
* $from/$to should be DATETIME strings.
|
||||
*/
|
||||
public static function listLogs(?string $from = null, ?string $to = null, ?string $type = null): array
|
||||
|
||||
@@ -9,7 +9,7 @@ class PaymentTransaction extends BaseModel
|
||||
{
|
||||
protected $table = 'payment_transactions';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -43,7 +43,7 @@ class PaymentTransaction extends BaseModel
|
||||
}
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function getTransactionsByPaymentId(int $paymentId): array
|
||||
|
||||
@@ -8,7 +8,7 @@ class PaypalTransaction extends BaseModel
|
||||
{
|
||||
protected $table = 'paypal_transactions';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -10,7 +10,7 @@ class Permission extends BaseModel
|
||||
{
|
||||
protected $table = 'permissions';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -21,7 +21,7 @@ class Permission extends BaseModel
|
||||
];
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ class Permission extends BaseModel
|
||||
|
||||
/**
|
||||
* Fetch permissions assigned to a specific role.
|
||||
* Returns rows similar to CI:
|
||||
* Returns rows similar to legacy:
|
||||
* role_permissions.* + permissions.name
|
||||
*/
|
||||
public static function getRolePermissions(int $roleId): array
|
||||
|
||||
@@ -8,7 +8,7 @@ class PlacementBatch extends BaseModel
|
||||
{
|
||||
protected $table = 'placement_batches';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class PlacementLevel extends BaseModel
|
||||
{
|
||||
protected $table = 'placement_levels';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class PlacementScore extends BaseModel
|
||||
{
|
||||
protected $table = 'placement_scores';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class Preferences extends BaseModel
|
||||
{
|
||||
protected $table = 'user_preferences';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -8,7 +8,7 @@ class PrintRequest extends BaseModel
|
||||
{
|
||||
protected $table = 'print_requests';
|
||||
|
||||
// ✅ CI: useTimestamps = true (created_at/updated_at)
|
||||
// ✅ legacy: useTimestamps = true (created_at/updated_at)
|
||||
public $timestamps = true;
|
||||
|
||||
protected $fillable = [
|
||||
|
||||
@@ -9,7 +9,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
class Project extends BaseModel
|
||||
{
|
||||
/**
|
||||
* Table name (your CI table is singular "project").
|
||||
* Table name (your legacy table is singular "project").
|
||||
*/
|
||||
protected $table = 'project';
|
||||
|
||||
@@ -101,7 +101,7 @@ class Project extends BaseModel
|
||||
/**
|
||||
* Calculate average project score for a student + term (+ optional class section).
|
||||
*
|
||||
* Enhancements vs CI version:
|
||||
* Enhancements vs legacy version:
|
||||
* - Uses SQL AVG for performance
|
||||
* - Ignores NULL, empty string, and non-numeric (best-effort) values
|
||||
* - Returns float|null
|
||||
@@ -133,7 +133,7 @@ class Project extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance method (so you can keep a similar calling style to CI).
|
||||
* Instance method (so you can keep a similar calling style to legacy).
|
||||
*/
|
||||
public function getAverageProjectScore(
|
||||
int $studentId,
|
||||
|
||||
@@ -108,7 +108,7 @@ class PromotionQueue extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional: keep the same CI signature (bool result).
|
||||
* Optional: keep the same legacy signature (bool result).
|
||||
*/
|
||||
public static function upsertBool(array $data): bool
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ class PurchaseOrder extends BaseModel
|
||||
|
||||
public static function rules(?int $id = null): array
|
||||
{
|
||||
// Mirrors CI: unique purchase_orders.po_number except current id.
|
||||
// Mirrors legacy: unique purchase_orders.po_number except current id.
|
||||
return [
|
||||
'po_number' => ['required', 'string', 'max:60', 'unique:purchase_orders,po_number,' . ($id ?? 'NULL') . ',id'],
|
||||
'supplier_id' => ['required', 'integer', 'min:1', 'exists:suppliers,id'],
|
||||
|
||||
@@ -78,7 +78,7 @@ class PurchaseOrderItem extends BaseModel
|
||||
public static function rules(bool $updating = false): array
|
||||
{
|
||||
// if updating, you might allow partial updates (sometimes)
|
||||
// keep strict by default to match CI behavior
|
||||
// keep strict by default to match legacy behavior
|
||||
return [
|
||||
'purchase_order_id' => [$updating ? 'sometimes' : 'required', 'integer', 'min:1', 'exists:purchase_orders,id'],
|
||||
'supply_id' => [$updating ? 'sometimes' : 'required', 'integer', 'min:1', 'exists:supplies,id'],
|
||||
|
||||
@@ -64,7 +64,7 @@ class Refund extends BaseModel
|
||||
|
||||
public static function paidOutStatuses(): array
|
||||
{
|
||||
// matches your CI whereIn(['Partial','Paid'])
|
||||
// matches your legacy whereIn(['Partial','Paid'])
|
||||
return [self::STATUS_PARTIAL, self::STATUS_PAID];
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ class Refund extends BaseModel
|
||||
|
||||
/**
|
||||
* Total paid-out refunds for a parent in a specific school year (Partial + Paid).
|
||||
* Mirrors the CI behavior and returns 0.00 if none.
|
||||
* Mirrors the legacy behavior and returns 0.00 if none.
|
||||
*/
|
||||
public static function totalApprovedPaidOutForParentAndYear(int $parentId, string $schoolYear): float
|
||||
{
|
||||
@@ -124,7 +124,7 @@ class Refund extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance-style method if you want to keep a similar calling style to CI.
|
||||
* Instance-style method if you want to keep a similar calling style to legacy.
|
||||
*/
|
||||
public function getTotalApprovedRefundByParentIdAndSchoolYear(int $parentId, string $schoolYear): float
|
||||
{
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ class Role extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* Helpers (CI-compatible)
|
||||
* Helpers (legacy-compatible)
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
@@ -112,7 +112,7 @@ public static function getIdsByNames(array $names): array
|
||||
}
|
||||
|
||||
/**
|
||||
* Equivalent to CI getRoles(): returns all roles.
|
||||
* Equivalent to legacy getRoles(): returns all roles.
|
||||
*/
|
||||
public static function getRoles()
|
||||
{
|
||||
|
||||
@@ -67,13 +67,13 @@ class RolePermission extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods
|
||||
* legacy-compatible methods
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetch permissions assigned to a specific role.
|
||||
* (CI: getRolePermissions)
|
||||
* (legacy: getRolePermissions)
|
||||
*/
|
||||
public static function getRolePermissions(int $roleId)
|
||||
{
|
||||
@@ -86,7 +86,7 @@ class RolePermission extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias (CI: getPermissionsByRole)
|
||||
* Alias (legacy: getPermissionsByRole)
|
||||
*/
|
||||
public static function getPermissionsByRole(int $roleId)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ class RolePermission extends BaseModel
|
||||
|
||||
/**
|
||||
* Delete all role_permissions rows for role.
|
||||
* (CI: deleteByRole)
|
||||
* (legacy: deleteByRole)
|
||||
*/
|
||||
public static function deleteByRole(int $roleId): int
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ class SchoolClass extends BaseModel
|
||||
{
|
||||
protected $table = 'classes';
|
||||
|
||||
// CI: useTimestamps = false
|
||||
// legacy: useTimestamps = false
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
@@ -24,7 +24,7 @@ class SchoolClass extends BaseModel
|
||||
];
|
||||
|
||||
/* =========================
|
||||
* CI method equivalents
|
||||
* legacy method equivalents
|
||||
* ========================= */
|
||||
|
||||
public static function getAllClasses()
|
||||
|
||||
@@ -11,7 +11,7 @@ class ScoreComment extends BaseModel
|
||||
protected $table = 'score_comments';
|
||||
|
||||
/**
|
||||
* CI: timestamps disabled (created_at handled by DB default).
|
||||
* legacy: timestamps disabled (created_at handled by DB default).
|
||||
* Keep disabled in Laravel too.
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -58,13 +58,13 @@ class Section extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods
|
||||
* legacy-compatible methods
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get section by name.
|
||||
* CI: getSectionByName()
|
||||
* legacy: getSectionByName()
|
||||
*/
|
||||
public static function getSectionByName(string $sectionName): ?self
|
||||
{
|
||||
@@ -73,7 +73,7 @@ class Section extends BaseModel
|
||||
|
||||
/**
|
||||
* Update section details by ID.
|
||||
* CI: updateSection() (Laravel automatically updates updated_at)
|
||||
* legacy: updateSection() (Laravel automatically updates updated_at)
|
||||
*/
|
||||
public static function updateSection(int $sectionId, array $data): bool
|
||||
{
|
||||
@@ -86,7 +86,7 @@ class Section extends BaseModel
|
||||
|
||||
/**
|
||||
* Delete section by ID.
|
||||
* CI: deleteSection()
|
||||
* legacy: deleteSection()
|
||||
*/
|
||||
public static function deleteSection(int $sectionId): bool
|
||||
{
|
||||
|
||||
@@ -134,7 +134,7 @@ class SemesterScore extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI-compatible boolean wrapper (matches your CI upsert(): bool).
|
||||
* legacy-compatible boolean wrapper (matches your legacy upsert(): bool).
|
||||
*/
|
||||
public static function upsertBool(array $data): bool
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@ class Setting extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI-compatible: getSettings()
|
||||
* legacy-compatible: getSettings()
|
||||
* Returns the settings model (single row).
|
||||
*/
|
||||
public static function getSettings(): self
|
||||
@@ -64,7 +64,7 @@ class Setting extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI-compatible: updateSettings($data)
|
||||
* legacy-compatible: updateSettings($data)
|
||||
* Updates the singleton row and returns bool.
|
||||
*/
|
||||
public static function updateSettings(array $data): bool
|
||||
|
||||
@@ -11,7 +11,7 @@ class Staff extends BaseModel
|
||||
protected $table = 'staff';
|
||||
|
||||
/**
|
||||
* CI: timestamps managed manually (created_at/updated_at set by caller/controller)
|
||||
* legacy: timestamps managed manually (created_at/updated_at set by caller/controller)
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
@@ -66,7 +66,7 @@ class Staff extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods
|
||||
* legacy-compatible methods
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
@@ -104,7 +104,7 @@ class Staff extends BaseModel
|
||||
|
||||
$userId = (int) $data['user_id'];
|
||||
|
||||
// Resolve school_year fallback like your CI logic
|
||||
// Resolve school_year fallback like your legacy logic
|
||||
$schoolYear = $data['school_year'] ?? null;
|
||||
if ($schoolYear === null) {
|
||||
$existingAny = static::query()
|
||||
@@ -177,7 +177,7 @@ class Staff extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI-compatible boolean wrapper if you want the same signature.
|
||||
* legacy-compatible boolean wrapper if you want the same signature.
|
||||
*/
|
||||
public static function upsertBool(array $data): bool
|
||||
{
|
||||
|
||||
@@ -248,7 +248,7 @@ class StaffAttendance extends BaseModel
|
||||
|
||||
/* ============================================================
|
||||
* Staff list with status for a day (users + roles + staff_attendance)
|
||||
* Mirrors your CI staffWithStatusForDay()
|
||||
* Mirrors your legacy staffWithStatusForDay()
|
||||
* ============================================================
|
||||
*/
|
||||
public static function staffWithStatusForDay(
|
||||
|
||||
@@ -34,7 +34,7 @@ class Stats extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI-compatible: getStats()
|
||||
* legacy-compatible: getStats()
|
||||
* Returns all rows.
|
||||
*/
|
||||
public static function getStats()
|
||||
|
||||
+16
-16
@@ -15,7 +15,7 @@ class Student extends BaseModel
|
||||
protected $table = 'students';
|
||||
|
||||
/**
|
||||
* CI: timestamps disabled
|
||||
* legacy: timestamps disabled
|
||||
*/
|
||||
public $timestamps = false;
|
||||
|
||||
@@ -106,11 +106,11 @@ class Student extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods (converted)
|
||||
* legacy-compatible methods (converted)
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/** CI: getNewStudents() */
|
||||
/** legacy: getNewStudents() */
|
||||
public static function getNewStudents(): array
|
||||
{
|
||||
return static::query()
|
||||
@@ -120,7 +120,7 @@ class Student extends BaseModel
|
||||
->all();
|
||||
}
|
||||
|
||||
/** CI: getNewStudentsWithParents() */
|
||||
/** legacy: getNewStudentsWithParents() */
|
||||
public static function getNewStudentsWithParents(): array
|
||||
{
|
||||
return DB::table('students')
|
||||
@@ -142,7 +142,7 @@ class Student extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getNewStudentsWithParentsAndEmergency()
|
||||
* legacy: getNewStudentsWithParentsAndEmergency()
|
||||
* Picks one emergency contact via MIN(...) with groupBy student.
|
||||
*/
|
||||
public static function getNewStudentsWithParentsAndEmergency(): array
|
||||
@@ -170,7 +170,7 @@ class Student extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getStudentsWithParentsAndEmergency(?schoolYear, ?isNew)
|
||||
* legacy: getStudentsWithParentsAndEmergency(?schoolYear, ?isNew)
|
||||
*/
|
||||
public static function getStudentsWithParentsAndEmergency(?string $schoolYear = null, ?int $isNew = null): array
|
||||
{
|
||||
@@ -209,26 +209,26 @@ class Student extends BaseModel
|
||||
->all();
|
||||
}
|
||||
|
||||
/** CI: getStudentSchoolIdByStudentId() */
|
||||
/** legacy: getStudentSchoolIdByStudentId() */
|
||||
public static function getStudentSchoolIdByStudentId(int $studentId): ?string
|
||||
{
|
||||
$v = static::query()->where('id', $studentId)->value('school_id');
|
||||
return $v !== null ? (string) $v : null;
|
||||
}
|
||||
|
||||
/** CI: getAllStudents() */
|
||||
/** legacy: getAllStudents() */
|
||||
public static function getAllStudents()
|
||||
{
|
||||
return static::query()->get();
|
||||
}
|
||||
|
||||
/** CI: getTotalStudents() */
|
||||
/** legacy: getTotalStudents() */
|
||||
public static function getTotalStudents(): int
|
||||
{
|
||||
return (int) static::query()->count();
|
||||
}
|
||||
|
||||
/** CI: getFullNameById() => returns [firstname, lastname] or null */
|
||||
/** legacy: getFullNameById() => returns [firstname, lastname] or null */
|
||||
public static function getFullNameById($studentId): ?array
|
||||
{
|
||||
$student = static::query()->find($studentId);
|
||||
@@ -242,13 +242,13 @@ class Student extends BaseModel
|
||||
return ['firstname' => $first, 'lastname' => $last];
|
||||
}
|
||||
|
||||
/** CI: getFullName($student array) */
|
||||
/** legacy: getFullName($student array) */
|
||||
public static function getFullName(array $student): string
|
||||
{
|
||||
return trim(($student['firstname'] ?? '') . ' ' . ($student['lastname'] ?? ''));
|
||||
}
|
||||
|
||||
/** CI: getLastRegistrationDate($ParentId) */
|
||||
/** legacy: getLastRegistrationDate($ParentId) */
|
||||
public static function getLastRegistrationDate(int $parentId): ?array
|
||||
{
|
||||
$row = static::query()
|
||||
@@ -261,7 +261,7 @@ class Student extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getByClassAndYear($class_section_id, $school_year, ?semester ignored)
|
||||
* legacy: getByClassAndYear($class_section_id, $school_year, ?semester ignored)
|
||||
*/
|
||||
public static function getByClassAndYear(int $classSectionId, string $schoolYear, ?string $semester = null): array
|
||||
{
|
||||
@@ -311,7 +311,7 @@ class Student extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getStudentsWithClassAndEnrollment()
|
||||
* legacy: getStudentsWithClassAndEnrollment()
|
||||
* Keeps your original grouping so behavior doesn’t change.
|
||||
*/
|
||||
public static function getStudentsWithClassAndEnrollment(): array
|
||||
@@ -335,8 +335,8 @@ class Student extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getStudentInfoByClassSectionId($classSectionId, $semester ignored, $schoolYear optional)
|
||||
* NOTE: In CI you appended updated_by from session; here we accept actor id.
|
||||
* legacy: getStudentInfoByClassSectionId($classSectionId, $semester ignored, $schoolYear optional)
|
||||
* NOTE: In legacy you appended updated_by from session; here we accept actor id.
|
||||
*/
|
||||
public static function getStudentInfoByClassSectionId(int $classSectionId, ?string $semester = null, ?string $schoolYear = null, ?int $actorId = null): array
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class StudentAllergy extends BaseModel
|
||||
protected $table = 'student_allergies';
|
||||
|
||||
/**
|
||||
* CI: timestamps disabled
|
||||
* legacy: timestamps disabled
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -51,13 +51,13 @@ class StudentAllergy extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods
|
||||
* legacy-compatible methods
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get all allergies for a given student.
|
||||
* CI: getAllergiesByStudentId()
|
||||
* legacy: getAllergiesByStudentId()
|
||||
*/
|
||||
public static function getAllergiesByStudentId(int $studentId): array
|
||||
{
|
||||
@@ -70,7 +70,7 @@ class StudentAllergy extends BaseModel
|
||||
|
||||
/**
|
||||
* Get allergies for multiple students, grouped by student_id.
|
||||
* CI: getAllergiesByStudentIds()
|
||||
* legacy: getAllergiesByStudentIds()
|
||||
*/
|
||||
public static function getAllergiesByStudentIds(array $studentIds): array
|
||||
{
|
||||
@@ -93,7 +93,7 @@ class StudentAllergy extends BaseModel
|
||||
|
||||
/* ============================================================
|
||||
* Validation rules helper (FormRequest/controller)
|
||||
* Mirrors CI validation intent
|
||||
* Mirrors legacy validation intent
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class StudentClass extends BaseModel
|
||||
|
||||
public function classSection(): BelongsTo
|
||||
{
|
||||
// Your CI joins on classSection.class_section_id
|
||||
// Your legacy joins on classSection.class_section_id
|
||||
return $this->belongsTo(ClassSection::class, 'class_section_id', 'class_section_id');
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class StudentClass extends BaseModel
|
||||
|
||||
/**
|
||||
* Scope: only students active for classes/attendance (joins students).
|
||||
* Mirrors CI active().
|
||||
* Mirrors legacy active().
|
||||
*/
|
||||
public function scopeActive(Builder $q): Builder
|
||||
{
|
||||
@@ -94,7 +94,7 @@ class StudentClass extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods (rewritten Laravel-style)
|
||||
* legacy-compatible methods (rewritten Laravel-style)
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
@@ -195,7 +195,7 @@ class StudentClass extends BaseModel
|
||||
|
||||
/**
|
||||
* Mirrors getStudentsByClassSectionIds()
|
||||
* Returns array rows (not models) like CI.
|
||||
* Returns array rows (not models) like legacy.
|
||||
*/
|
||||
public static function getStudentsByClassSectionIds(array $classSectionIds): array
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class StudentMedicalCondition extends BaseModel
|
||||
protected $table = 'student_medical_conditions';
|
||||
|
||||
/**
|
||||
* CI: timestamps disabled
|
||||
* legacy: timestamps disabled
|
||||
*/
|
||||
public $timestamps = true;
|
||||
|
||||
@@ -51,13 +51,13 @@ class StudentMedicalCondition extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods
|
||||
* legacy-compatible methods
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get all medical conditions for a given student.
|
||||
* CI: getMedicalByStudentId()
|
||||
* legacy: getMedicalByStudentId()
|
||||
*/
|
||||
public static function getMedicalByStudentId(int $studentId): array
|
||||
{
|
||||
@@ -70,7 +70,7 @@ class StudentMedicalCondition extends BaseModel
|
||||
|
||||
/**
|
||||
* Get medical conditions for multiple students, grouped by student_id.
|
||||
* CI: getMedicalByStudentIds()
|
||||
* legacy: getMedicalByStudentIds()
|
||||
*/
|
||||
public static function getMedicalByStudentIds(array $studentIds): array
|
||||
{
|
||||
@@ -91,7 +91,7 @@ class StudentMedicalCondition extends BaseModel
|
||||
|
||||
/* ============================================================
|
||||
* Validation helper (FormRequest/controller)
|
||||
* Mirrors CI rules/messages
|
||||
* Mirrors legacy rules/messages
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
|
||||
@@ -61,12 +61,12 @@ class SubjectCurriculum extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible method
|
||||
* legacy-compatible method
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* CI: getOptionsForClass($classId, $subject)
|
||||
* legacy: getOptionsForClass($classId, $subject)
|
||||
*/
|
||||
public static function getOptionsForClass(int $classId, string $subject): array
|
||||
{
|
||||
|
||||
+15
-15
@@ -56,7 +56,7 @@ class TeacherClass extends BaseModel
|
||||
|
||||
public function classSection(): BelongsTo
|
||||
{
|
||||
// CI frequently joins on classSection.class_section_id
|
||||
// legacy frequently joins on classSection.class_section_id
|
||||
return $this->belongsTo(ClassSection::class, 'class_section_id', 'class_section_id');
|
||||
}
|
||||
|
||||
@@ -95,18 +95,18 @@ class TeacherClass extends BaseModel
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CI-compatible methods (converted)
|
||||
* legacy-compatible methods (converted)
|
||||
* ============================================================
|
||||
*/
|
||||
|
||||
/** CI: getClassSectionIdByUserId() */
|
||||
/** legacy: getClassSectionIdByUserId() */
|
||||
public static function getClassSectionIdByUserId(int $userId): ?self
|
||||
{
|
||||
return static::query()->forTeacher($userId)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getClassAssignmentsByUserId()
|
||||
* legacy: getClassAssignmentsByUserId()
|
||||
* Returns array rows with:
|
||||
* class_section_pk, class_section_id, class_section_name, class_id, class_name, teacher_id, teacher_role, school_year, semester
|
||||
*/
|
||||
@@ -171,7 +171,7 @@ class TeacherClass extends BaseModel
|
||||
->all();
|
||||
}
|
||||
|
||||
/** CI: getClassSectionsByTeacherId() */
|
||||
/** legacy: getClassSectionsByTeacherId() */
|
||||
public static function getClassSectionsByTeacherId(int $teacherId): array
|
||||
{
|
||||
$rows = DB::table('teacher_class as tc')
|
||||
@@ -194,7 +194,7 @@ class TeacherClass extends BaseModel
|
||||
];
|
||||
}
|
||||
|
||||
/** CI: getClassByTeacherId() */
|
||||
/** legacy: getClassByTeacherId() */
|
||||
public static function getClassByTeacherId(int $teacherId): array
|
||||
{
|
||||
return DB::table('teacher_class as tc')
|
||||
@@ -207,7 +207,7 @@ class TeacherClass extends BaseModel
|
||||
->all();
|
||||
}
|
||||
|
||||
/** CI: getTeacherIdByClassSection($classSectionName, $semester, $schoolYear) */
|
||||
/** legacy: getTeacherIdByClassSection($classSectionName, $semester, $schoolYear) */
|
||||
public static function getTeacherIdByClassSection(string $classSectionName, string $semester, string $schoolYear): ?int
|
||||
{
|
||||
$classSectionName = trim($classSectionName);
|
||||
@@ -232,12 +232,12 @@ class TeacherClass extends BaseModel
|
||||
return $teacherId ? (int) $teacherId : null;
|
||||
}
|
||||
|
||||
/** CI: getMainTeacherBySection($classSectionName, $semester, $schoolYear) */
|
||||
/** legacy: getMainTeacherBySection($classSectionName, $semester, $schoolYear) */
|
||||
public static function getMainTeacherBySection(string $classSectionName, string $semester, string $schoolYear): ?array
|
||||
{
|
||||
$row = DB::table('classSection as cs')
|
||||
->selectRaw('u.id AS teacher_id, u.firstname, u.lastname')
|
||||
// IMPORTANT: your CI code had tc.class_section_id = cs.id in one place (PK join),
|
||||
// IMPORTANT: your legacy code had tc.class_section_id = cs.id in one place (PK join),
|
||||
// but most of your code uses class_section_id code join.
|
||||
// Here we keep the "code join" for consistency:
|
||||
->join('teacher_class as tc', 'tc.class_section_id', '=', 'cs.class_section_id')
|
||||
@@ -251,7 +251,7 @@ class TeacherClass extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: assignTeacherToClass()
|
||||
* legacy: assignTeacherToClass()
|
||||
* Upsert by (teacher_id, class_section_id, school_year, position) and touch updated_at.
|
||||
*/
|
||||
public static function assignTeacherToClass(
|
||||
@@ -286,8 +286,8 @@ class TeacherClass extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: getAssignedClassSections()
|
||||
* NOTE: your CI joins classSection.id = teacher_class.class_section_id (PK join).
|
||||
* legacy: getAssignedClassSections()
|
||||
* NOTE: your legacy joins classSection.id = teacher_class.class_section_id (PK join).
|
||||
* If your teacher_class.class_section_id is actually a section CODE, change join to cs.class_section_id.
|
||||
*/
|
||||
public static function getAssignedClassSections(int $teacherId, string $schoolYear, string $semester): array
|
||||
@@ -304,7 +304,7 @@ class TeacherClass extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: assignedForSectionTerm()
|
||||
* legacy: assignedForSectionTerm()
|
||||
* Returns rows: class_section_id, teacher_id, position, firstname, lastname
|
||||
*
|
||||
* @param int|null $alsoSectionCode When teacher_class rows use the section PK while $sectionCode
|
||||
@@ -347,7 +347,7 @@ class TeacherClass extends BaseModel
|
||||
->all();
|
||||
}
|
||||
|
||||
/** CI: assignedMapForSectionTerm() */
|
||||
/** legacy: assignedMapForSectionTerm() */
|
||||
public static function assignedMapForSectionTerm(
|
||||
int $sectionCode,
|
||||
string $semester,
|
||||
@@ -363,7 +363,7 @@ class TeacherClass extends BaseModel
|
||||
}
|
||||
|
||||
/**
|
||||
* CI: assignedBySectionForTerm()
|
||||
* legacy: assignedBySectionForTerm()
|
||||
* Returns: [sectionCode] => [rows...]
|
||||
*/
|
||||
public static function assignedBySectionForTerm(string $semester, string $schoolYear, ?array $onlySectionCodes = null): array
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user