<?php

/**

 * Validation Rules for Different Data Types

 * Matches actual database schema

 */



return [

    'students' => [

        'student_id' => [

            'required' => true,

            'unique' => ['table' => 'students', 'field' => 'student_id']

        ],

        'first_name' => [

            'required' => true

        ],

        'last_name' => [

            'required' => true

        ],

        'class' => [

            'required' => true

        ],

        'father_phone' => [

            'phone' => true

        ],

        'mother_phone' => [

            'phone' => true

        ],

        'phone' => [

            'phone' => true

        ],

        'emergency_contact_phone' => [

            'phone' => true

        ],

        'email' => [

            'email' => true

        ],

        'date_of_birth' => [

            'date' => true

        ]

    ],

    

    'staff' => [

        'staff_id' => [

            'required' => true,

            'unique' => ['table' => 'staff', 'field' => 'staff_id']

        ],

        'full_name' => [

            'required' => true

        ],

        'phone' => [

            'phone' => true

        ],

        'email' => [

            'email' => true

        ],

        'salary' => [

            'numeric' => true,

            'min' => 0

        ],

        'date_of_birth' => [

            'date' => true

        ],

        'date_of_employment' => [

            'date' => true

        ]

    ],

    

    'fees' => [

        'class_name' => [

            'required' => true,

            'message' => 'Class name is required'

        ],

        'fee_type' => [

            'required' => true,

            'message' => 'Fee type is required'

        ],

        'amount' => [

            'required' => true,

            'numeric' => true,

            'min' => 0,

            'message' => 'Amount must be a positive number'

        ],

        'due_date' => [

            'required' => true,

            'date' => true,

            'message' => 'Due date must be in YYYY-MM-DD format'

        ],

        'academic_year' => [

            'required' => true,

            'pattern' => '/^\d{4}-\d{4}$/',

            'message' => 'Academic year must be in format YYYY-YYYY (e.g., 2025-2026)'

        ]

    ],

    

    'payments' => [

        'student_id' => [

            'required' => true,

            'exists' => ['table' => 'students', 'field' => 'student_id'],

            'message' => 'Student ID must exist in database'

        ],

        'fee_structure_id' => [

            'required' => true,

            'numeric' => true,

            'exists' => ['table' => 'fee_structures', 'field' => 'id'],

            'message' => 'Fee structure ID must exist in database'

        ],

        'amount_paid' => [

            'required' => true,

            'numeric' => true,

            'min' => 0,

            'message' => 'Amount paid must be a positive number'

        ],

        'payment_date' => [

            'required' => true,

            'date' => true,

            'message' => 'Payment date must be in YYYY-MM-DD format'

        ],

        'payment_method' => [

            'in' => ['cash', 'card', 'bank_transfer', 'online'],

            'message' => 'Payment method must be cash, card, bank_transfer, or online'

        ]

    ],

    

    'subjects' => [

        'subject_name' => [

            'required' => true

        ],

        'subject_code' => [

            'required' => true,

            'unique' => ['table' => 'subjects', 'field' => 'subject_code']

        ]

    ],

    

    'class_subjects' => [

        'class_name' => [

            'required' => true

        ],

        'subject_id' => [

            'required' => true,

            'exists' => ['table' => 'subjects', 'field' => 'id']

        ],

        'class_score_percent' => [

            'numeric' => true,

            'min' => 0,

            'max' => 100

        ],

        'exam_score_percent' => [

            'numeric' => true,

            'min' => 0,

            'max' => 100

        ]

    ]

];

?>