add projet
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
|
||||
class SemesterScore extends BaseModel
|
||||
{
|
||||
protected $table = 'semester_scores';
|
||||
protected $primaryKey = 'id';
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'school_id',
|
||||
'class_section_id',
|
||||
'updated_by',
|
||||
'homework_avg',
|
||||
'quiz_avg',
|
||||
'project_avg',
|
||||
'midterm_exam_score',
|
||||
'final_exam_score',
|
||||
'attendance_score',
|
||||
'participation_score',
|
||||
'ptap_score',
|
||||
'test_avg',
|
||||
'semester_score',
|
||||
'semester',
|
||||
'school_year',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
];
|
||||
public $timestamps = true;
|
||||
|
||||
/**
|
||||
* Insert or update a semester score record
|
||||
*/
|
||||
// In SemesterScore.php
|
||||
|
||||
public function upsert(array $data): bool
|
||||
{
|
||||
// First check if record exists
|
||||
$existing = $this->where([
|
||||
'student_id' => $data['student_id'],
|
||||
'semester' => $data['semester'],
|
||||
'school_year' => $data['school_year']
|
||||
])->first();
|
||||
|
||||
// If exists - UPDATE
|
||||
if ($existing) {
|
||||
return $this->update($existing['id'], $data);
|
||||
}
|
||||
// If new - INSERT
|
||||
else {
|
||||
return $this->insert($data) !== false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user