fix gitlab tests
This commit is contained in:
+20
-19
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Staff extends BaseModel
|
||||
@@ -29,9 +30,9 @@ class Staff extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'user_id' => 'integer',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'user_id' => 'integer',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
];
|
||||
|
||||
/* ============================================================
|
||||
@@ -136,7 +137,7 @@ class Staff extends BaseModel
|
||||
// generated email. If an exact school-year row is missing but the user
|
||||
// already has any staff row, update that existing row instead of trying
|
||||
// to insert a duplicate-email record.
|
||||
if (! $existing) {
|
||||
if (!$existing) {
|
||||
$existing = static::query()
|
||||
->where('user_id', $userId)
|
||||
->orderByDesc('id')
|
||||
@@ -150,11 +151,11 @@ class Staff extends BaseModel
|
||||
|
||||
if ($existing) {
|
||||
// Preserve original created_at unless explicitly provided
|
||||
if (! array_key_exists('created_at', $payload) && $existing->created_at) {
|
||||
if (!array_key_exists('created_at', $payload) && $existing->created_at) {
|
||||
$payload['created_at'] = $existing->created_at;
|
||||
}
|
||||
// Ensure updated_at exists
|
||||
if (! array_key_exists('updated_at', $payload)) {
|
||||
if (!array_key_exists('updated_at', $payload)) {
|
||||
$payload['updated_at'] = $now;
|
||||
}
|
||||
|
||||
@@ -165,10 +166,10 @@ class Staff extends BaseModel
|
||||
}
|
||||
|
||||
// Insert new row — set created_at/updated_at if not provided
|
||||
if (! array_key_exists('created_at', $payload)) {
|
||||
if (!array_key_exists('created_at', $payload)) {
|
||||
$payload['created_at'] = $now;
|
||||
}
|
||||
if (! array_key_exists('updated_at', $payload)) {
|
||||
if (!array_key_exists('updated_at', $payload)) {
|
||||
$payload['updated_at'] = $now;
|
||||
}
|
||||
|
||||
@@ -193,17 +194,17 @@ class Staff extends BaseModel
|
||||
$req = $updating ? 'sometimes' : 'required';
|
||||
|
||||
return [
|
||||
'user_id' => [$req, 'integer', 'min:1', 'exists:users,id'],
|
||||
'firstname' => ['nullable', 'string', 'max:120'],
|
||||
'lastname' => ['nullable', 'string', 'max:120'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:40'],
|
||||
'role_name' => ['nullable', 'string', 'max:80'],
|
||||
'active_role' => ['nullable', 'string', 'max:80'], // includes 'inactive'
|
||||
'status' => ['nullable', 'string', 'max:40'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'created_at' => ['nullable', 'date'],
|
||||
'updated_at' => ['nullable', 'date'],
|
||||
'user_id' => [$req, 'integer', 'min:1', 'exists:users,id'],
|
||||
'firstname' => ['nullable', 'string', 'max:120'],
|
||||
'lastname' => ['nullable', 'string', 'max:120'],
|
||||
'email' => ['nullable', 'email', 'max:255'],
|
||||
'phone' => ['nullable', 'string', 'max:40'],
|
||||
'role_name' => ['nullable', 'string', 'max:80'],
|
||||
'active_role' => ['nullable', 'string', 'max:80'], // includes 'inactive'
|
||||
'status' => ['nullable', 'string', 'max:40'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'created_at' => ['nullable', 'date'],
|
||||
'updated_at' => ['nullable', 'date'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user