add test batches
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Models\BaseModel;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class ReimbursementBatchItem extends BaseModel
|
||||
@@ -27,12 +28,12 @@ class ReimbursementBatchItem extends BaseModel
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'batch_id' => 'integer',
|
||||
'expense_id' => 'integer',
|
||||
'batch_id' => 'integer',
|
||||
'expense_id' => 'integer',
|
||||
'reimbursement_id' => 'integer',
|
||||
'admin_id' => 'integer',
|
||||
'assigned_at' => 'datetime',
|
||||
'unassigned_at' => 'datetime',
|
||||
'admin_id' => 'integer',
|
||||
'assigned_at' => 'datetime',
|
||||
'unassigned_at' => 'datetime',
|
||||
];
|
||||
|
||||
/* ============================================================
|
||||
@@ -84,14 +85,14 @@ class ReimbursementBatchItem extends BaseModel
|
||||
public function scopeAssigned(Builder $q): Builder
|
||||
{
|
||||
return $q->whereNotNull('admin_id')
|
||||
->whereNotNull('assigned_at')
|
||||
->whereNull('unassigned_at');
|
||||
->whereNotNull('assigned_at')
|
||||
->whereNull('unassigned_at');
|
||||
}
|
||||
|
||||
public function scopeUnassigned(Builder $q): Builder
|
||||
{
|
||||
return $q->whereNull('admin_id')
|
||||
->whereNull('assigned_at');
|
||||
->whereNull('assigned_at');
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
@@ -136,15 +137,15 @@ class ReimbursementBatchItem extends BaseModel
|
||||
public static function rules(bool $updating = false): array
|
||||
{
|
||||
return [
|
||||
'batch_id' => [$updating ? 'sometimes' : 'required', 'integer', 'min:1', 'exists:reimbursement_batches,id'],
|
||||
'expense_id' => ['nullable', 'integer', 'exists:expenses,id'],
|
||||
'batch_id' => [$updating ? 'sometimes' : 'required', 'integer', 'min:1', 'exists:reimbursement_batches,id'],
|
||||
'expense_id' => ['nullable', 'integer', 'exists:expenses,id'],
|
||||
'reimbursement_id' => ['nullable', 'integer', 'exists:reimbursements,id'],
|
||||
'admin_id' => ['nullable', 'integer'], // add exists rule if you know the table
|
||||
'assigned_at' => ['nullable', 'date'],
|
||||
'unassigned_at' => ['nullable', 'date', 'after_or_equal:assigned_at'],
|
||||
'notes' => ['nullable', 'string', 'max:5000'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'semester' => ['nullable', 'string', 'max:20'],
|
||||
'admin_id' => ['nullable', 'integer'], // add exists rule if you know the table
|
||||
'assigned_at' => ['nullable', 'date'],
|
||||
'unassigned_at' => ['nullable', 'date', 'after_or_equal:assigned_at'],
|
||||
'notes' => ['nullable', 'string', 'max:5000'],
|
||||
'school_year' => ['nullable', 'string', 'max:20'],
|
||||
'semester' => ['nullable', 'string', 'max:20'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user