fix gitlab tests
This commit is contained in:
+17
-19
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -27,10 +28,10 @@ class LateSlipLog extends BaseModel
|
||||
|
||||
protected $casts = [
|
||||
'printed_by' => 'integer',
|
||||
'slip_date' => 'date', // slip_date is Y-m-d
|
||||
'slip_date' => 'date', // slip_date is Y-m-d
|
||||
'printed_at' => 'datetime',
|
||||
// time_in is often stored as TIME or string; keep as string unless you store as DATETIME
|
||||
'time_in' => 'string',
|
||||
'time_in' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -40,30 +41,27 @@ class LateSlipLog extends BaseModel
|
||||
public static function logSlip(array $data, ?int $printedBy): bool
|
||||
{
|
||||
$row = [
|
||||
'school_year' => (string) ($data['school_year'] ?? ''),
|
||||
'semester' => (string) ($data['semester'] ?? ''),
|
||||
'student_name' => (string) ($data['student_name'] ?? ''),
|
||||
'slip_date' => $data['slip_date'] ?? null, // Y-m-d
|
||||
'time_in' => $data['time_in'] ?? null, // H:i:s
|
||||
'grade' => (string) ($data['grade'] ?? ''),
|
||||
'reason' => (string) ($data['reason'] ?? ''),
|
||||
'admin_name' => (string) ($data['admin_name'] ?? ''),
|
||||
'printed_by' => $printedBy,
|
||||
'printed_at' => now(), // use UTC if your app timezone is UTC
|
||||
'school_year' => (string)($data['school_year'] ?? ''),
|
||||
'semester' => (string)($data['semester'] ?? ''),
|
||||
'student_name' => (string)($data['student_name'] ?? ''),
|
||||
'slip_date' => $data['slip_date'] ?? null, // Y-m-d
|
||||
'time_in' => $data['time_in'] ?? null, // H:i:s
|
||||
'grade' => (string)($data['grade'] ?? ''),
|
||||
'reason' => (string)($data['reason'] ?? ''),
|
||||
'admin_name' => (string)($data['admin_name'] ?? ''),
|
||||
'printed_by' => $printedBy,
|
||||
'printed_at' => now(), // use UTC if your app timezone is UTC
|
||||
];
|
||||
|
||||
try {
|
||||
// create() returns model; treat as success if created
|
||||
$created = static::query()->create($row);
|
||||
|
||||
return ! empty($created->id);
|
||||
return !empty($created->id);
|
||||
} catch (QueryException $e) {
|
||||
Log::error('LateSlipLog::logSlip failed: '.$e->getMessage());
|
||||
|
||||
Log::error('LateSlipLog::logSlip failed: ' . $e->getMessage());
|
||||
return false;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('LateSlipLog::logSlip failed: '.$e->getMessage());
|
||||
|
||||
Log::error('LateSlipLog::logSlip failed: ' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -73,4 +71,4 @@ class LateSlipLog extends BaseModel
|
||||
{
|
||||
return $this->belongsTo(User::class, 'printed_by');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user