add projet
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class PromotionQueue extends BaseModel
|
||||
{
|
||||
protected $table = 'promotion_queue';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'from_class_section_id',
|
||||
'to_class_id',
|
||||
'to_class_section_id',
|
||||
'school_year_from',
|
||||
'school_year_to',
|
||||
'status',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'updated_by',
|
||||
];
|
||||
public $timestamps = true;
|
||||
const CREATED_AT = 'created_at';
|
||||
const UPDATED_AT = 'updated_at';
|
||||
|
||||
public function upsert(array $data): bool
|
||||
{
|
||||
if (empty($data['student_id']) || empty($data['school_year_to'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$existing = $this->where('student_id', (int)$data['student_id'])
|
||||
->where('school_year_to', (string)$data['school_year_to'])
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return (bool) $this->update((int)$existing[$this->primaryKey], array_merge($existing, $data));
|
||||
}
|
||||
|
||||
return (bool) $this->insert($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user