Fix Pint formatting
This commit is contained in:
+19
-20
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class Staff extends BaseModel
|
||||
@@ -30,9 +29,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',
|
||||
];
|
||||
|
||||
/* ============================================================
|
||||
@@ -137,7 +136,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')
|
||||
@@ -151,11 +150,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;
|
||||
}
|
||||
|
||||
@@ -166,10 +165,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;
|
||||
}
|
||||
|
||||
@@ -194,17 +193,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