Archived
33 lines
719 B
PHP
33 lines
719 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class ItemModel extends model {
|
|
protected $table = 'item';
|
|
|
|
public function getItem($itemId = false) {
|
|
if ($itemId === false) {
|
|
return $this->findAll();
|
|
}
|
|
|
|
return $this->where(['itemId' => $itemId])->first();
|
|
}
|
|
|
|
public function getCount() {
|
|
return $this->db->count_all($this->table);
|
|
}
|
|
|
|
public function getStar(?int $perPage = null): array
|
|
{
|
|
$this->builder()
|
|
->select('item.*, star.star')
|
|
->join('star', 'star.itemId = item.itemId');
|
|
return [
|
|
'star' => $this->paginate($perPage),
|
|
'starpager' => $this->pager,
|
|
];
|
|
}
|
|
}
|