fix parent, teacher and admin pages
This commit is contained in:
+13
-1
@@ -132,6 +132,18 @@ class Staff extends BaseModel
|
||||
->first();
|
||||
}
|
||||
|
||||
// The table enforces unique email addresses, so a user cannot safely
|
||||
// have multiple staff rows across different school years with the same
|
||||
// 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) {
|
||||
$existing = static::query()
|
||||
->where('user_id', $userId)
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
}
|
||||
|
||||
$now = now(); // use UTC if app.timezone=UTC (recommended)
|
||||
|
||||
// Only allow fillable keys
|
||||
@@ -195,4 +207,4 @@ class Staff extends BaseModel
|
||||
'updated_at' => ['nullable', 'date'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user