'integer', 'teachers' => 'integer', 'admins' => 'integer', 'users' => 'integer', ]; /** * CI-compatible: getStats() * Returns all rows. */ public static function getStats() { return static::query()->get(); } /** * Enhancement: if you treat stats as a single row (common), * this returns the first row, creating it with zeros if missing. */ public static function singleton(): self { return static::query()->first() ?? static::query()->create([ 'students' => 0, 'teachers' => 0, 'admins' => 0, 'users' => 0, ]); } /** * Enhancement: update singleton stats safely. */ public static function updateSingleton(array $data): self { $row = static::singleton(); $row->fill($data); $row->save(); return $row; } }