57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class InventoryItemModel extends Model
|
|
{
|
|
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',
|
|
'sku',
|
|
'notes',
|
|
|
|
// academic tags
|
|
'semester',
|
|
'school_year',
|
|
|
|
// audit
|
|
'updated_by',
|
|
|
|
// classroom state buckets
|
|
'good_qty',
|
|
'needs_repair_qty',
|
|
'need_replace_qty',
|
|
'cannot_find_qty',
|
|
];
|
|
|
|
|
|
protected $validationRules = [
|
|
'type' => 'required|in_list[classroom,book,office,kitchen]',
|
|
'name' => 'required|min_length[2]',
|
|
'quantity' => 'permit_empty|integer',
|
|
'unit_price' => 'permit_empty|decimal',
|
|
'semester' => 'permit_empty|in_list[Spring,Fall]',
|
|
'school_year' => 'permit_empty|max_length[16]', // e.g. 2025-2026
|
|
];
|
|
}
|