60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class JobPositionModel extends Model
|
|
{
|
|
protected $table = 'job_positions';
|
|
protected $primaryKey = 'position_id';
|
|
protected $useAutoIncrement = false;
|
|
protected $returnType = 'array';
|
|
protected $allowedFields = [
|
|
'position_id',
|
|
'template_id',
|
|
'title',
|
|
'description',
|
|
'department',
|
|
'location',
|
|
'employment_type',
|
|
'responsibilities',
|
|
'requirements',
|
|
'status',
|
|
'posted_by',
|
|
'posted_at',
|
|
'details_click_count',
|
|
'created_at',
|
|
'updated_at',
|
|
];
|
|
protected $useTimestamps = true;
|
|
protected $createdField = 'created_at';
|
|
protected $updatedField = 'updated_at';
|
|
|
|
public function openPositions(): array
|
|
{
|
|
return $this
|
|
->where('status', 'open')
|
|
->orderBy('posted_at', 'DESC')
|
|
->orderBy('created_at', 'DESC')
|
|
->findAll();
|
|
}
|
|
|
|
public function recordDetailsClick(string $positionId): bool
|
|
{
|
|
return $this->builder()
|
|
->set('details_click_count', 'COALESCE(details_click_count, 0) + 1', false)
|
|
->where('position_id', $positionId)
|
|
->where('status', 'open')
|
|
->update();
|
|
}
|
|
|
|
public function adminPositions(): array
|
|
{
|
|
return $this
|
|
->orderBy('updated_at', 'DESC')
|
|
->orderBy('created_at', 'DESC')
|
|
->findAll();
|
|
}
|
|
}
|