Files
alrahma_sunday_school/app/Models/InventoryItemModel.php
T
root d906a915d6
Deploy to Shared Hosting / Shared hosting deploy (push) Failing after 47s
Tests / PHPUnit (push) Failing after 1m20s
add refund logic and fix books inventory logic
2026-08-22 13:44:25 -04:00

60 lines
1.4 KiB
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
use App\Models\Concerns\SchoolYearAutoFillTrait;
class InventoryItemModel extends Model
{
use SchoolYearAutoFillTrait;
protected $table = 'inventory_items';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $useTimestamps = true;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
// IMPORTANT: include everything you ever update/insert
protected $allowedFields = [
'type',
'category_id',
'name',
'description',
'quantity', // <- recalcQuantity updates this
'unit',
'condition',
'isbn',
'edition',
'author',
'sku',
'is_active',
'retired_at',
'isbn_edition_key',
'sku_normalized',
'notes',
// audit
'updated_by',
// classroom state buckets
'good_qty',
'needs_repair_qty',
'need_replace_qty',
'cannot_find_qty',
'school_year',
];
protected $validationRules = [
'type' => 'required|in_list[classroom,book,office,kitchen]',
'name' => 'required|min_length[2]',
'quantity' => 'permit_empty|integer',
'school_year' => 'required|string|max_length[16]',
];
}