'integer', 'admin_id' => 'integer', 'uploaded_by' => 'integer', 'uploaded_at' => 'datetime', ]; /* ============================================================ * Relationships (optional but recommended) * ============================================================ */ public function batch(): BelongsTo { return $this->belongsTo(ReimbursementBatch::class, 'batch_id'); } public function admin(): BelongsTo { // Change Admin to your actual user/admin model if different return $this->belongsTo(Admin::class, 'admin_id'); } public function uploader(): BelongsTo { // If uploaded_by references the same admins/users table return $this->belongsTo(Admin::class, 'uploaded_by'); } /* ============================================================ * Convenience helpers * ============================================================ */ /** * Create an admin file row and auto-set uploaded_at if missing. */ public static function createForBatch(array $data): self { if (empty($data['uploaded_at'])) { $data['uploaded_at'] = now(); } return static::create($data); } /** * Optional: validation rules helper (use in FormRequest/controller). */ public static function rules(bool $updating = false): array { return [ 'batch_id' => [$updating ? 'sometimes' : 'required', 'integer', 'min:1', 'exists:reimbursement_batches,id'], 'admin_id' => [$updating ? 'sometimes' : 'required', 'integer', 'min:1', 'exists:admins,id'], // adjust table 'filename' => [$updating ? 'sometimes' : 'required', 'string', 'max:255'], 'original_filename' => ['nullable', 'string', 'max:255'], 'uploaded_at' => ['nullable', 'date'], 'uploaded_by' => ['nullable', 'integer'], ]; } }