recreate project
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?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
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user