<?php
namespace App\Models;

use CodeIgniter\Model;

class BarcodeModel extends Model
{
    protected $table = 'barcodes';
    protected $primaryKey = 'id';
    protected $allowedFields = ['barcode', 'scanned_at'];

    public function isDuplicate($barcode)
    {
        return $this->where('barcode', $barcode)->first() !== null;
    }

    public function countBarcodes()
    {
        return $this->countAllResults();
    }
}

