HEX
Server: nginx/1.24.0
System: Linux DGT-WORDPRESS-VM-SERVER 6.14.0-1017-azure #17~24.04.1-Ubuntu SMP Mon Dec 1 20:10:50 UTC 2025 x86_64
User: ubuntu (1000)
PHP: 8.4.12
Disabled: NONE
Upload Files
File: /mnt/data/ghayatcom/ghayatcom-api/database/seeders/AppointmentSeeder.php
<?php

namespace Database\Seeders;

use App\Appointment;
use App\AppointmentLogs;
use App\AppointmentReason;
use App\AppointmentSymptom;
use App\Payment;
use App\AdminSettings;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Config;
use OpenTok\ArchiveMode;
use OpenTok\MediaMode;
use OpenTok\OpenTok;
use OpenTok\Role;
use OpenTok\Session;

class AppointmentSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $datas = [
            1 => [
                'consultation_id' => '00000001',
                'consultation_type' => '2',
                'clinic_appointment_id' => '1',
                'sick_leave_verification' => '1',
                'appointment_start_dt' => date('Y-m-d H:i:s', strtotime('10:00:00')),
                'appointment_end_dt' => date('Y-m-d H:i:s', strtotime('10:30:00')),
                'home_visit_dt' => date('Y-m-d'),
                'home_visit_range' => '[{"from":"08:00","to":"12:00"},{"from":"14:00","to":"18:00"}]',
                'departure_time' => date('Y-m-d H:i:s', strtotime('09:30:00')),
                'lat' => '15.835213987126',
                'long' => '78.005928693867',
                'lat_long_address' => 'Coimbatore',
                'patient_id' => '2',
                'doctor_id' => '3',
                'appointment_status' => 'ACCEPTED',
            ],
            2 => [
                'consultation_id' => '00000002',
                'consultation_type' => '1',
                'clinic_appointment_id' => '2',
                'sick_leave_verification' => '1',
                'channel' => '1',
                'appointment_start_dt' => date('Y-m-d H:i:s', strtotime('11:30:00')),
                'appointment_end_dt' => date('Y-m-d H:i:s', strtotime('11:45:00')),
                'patient_id' => '2',
                'doctor_id' => '3',
                'appointment_status' => 'ACCEPTED',
            ],
            3 => [
                'consultation_id' => '00000003',
                'consultation_type' => '3',
                'clinic_appointment_id' => '3',
                'sick_leave_verification' => '1',
                'channel' => '1',
                'appointment_start_dt' => date('Y-m-d H:i:s', strtotime('12:30:00')),
                'appointment_end_dt' => date('Y-m-d H:i:s', strtotime('12:45:00')),
                'patient_id' => '2',
                'doctor_id' => '3',
                'appointment_status' => 'ACCEPTED',
            ],
        ];

        $logDatas = [
            1 => [
                'appointment_id' => '1',
                'slug' => 'new_appointment',
                'data' => '{"message":"New Appointment Requested to doctor"}',
                'time_at' => date('Y-m-d H:i:s'),
            ],
            2 => [
                'appointment_id' => '2',
                'slug' => 'new_appointment',
                'data' => '{"message":"New Appointment Requested to doctor"}',
                'time_at' => date('Y-m-d H:i:s'),
            ],
            3 => [
                'appointment_id' => '3',
                'slug' => 'new_appointment',
                'data' => '{"message":"New Appointment Requested to doctor"}',
                'time_at' => date('Y-m-d H:i:s'),
            ],
        ];

        $reasonDatas = [
            1 => [
                'appointment_id' => '1',
                'reasons_text' => 'Headache',
                'reasons_document' => '["dummy_file_1.jpg"]',
            ],
            2 => [
                'appointment_id' => '2',
                'reasons_text' => 'Fever',
                'reasons_document' => '["dummy_file_2.jpg"]',
            ],
            3 => [
                'appointment_id' => '3',
                'reasons_text' => 'Headache',
                'reasons_document' => '["dummy_file_3.jpg"]',
            ],
        ];

        $symptomDatas = [
            1 => [
                'appointment_id' => '1',
                'symptom_id' => '8',
            ],
            2 => [
                'appointment_id' => '1',
                'symptom_id' => '9',
            ],
            3 => [
                'appointment_id' => '2',
                'symptom_id' => '1',
            ],
            4 => [
                'appointment_id' => '2',
                'symptom_id' => '2',
            ],
            5 => [
                'appointment_id' => '3',
                'symptom_id' => '5',
            ],
            6 => [
                'appointment_id' => '3',
                'symptom_id' => '6',
            ],
        ];

        $paymentDatas = [
            1 => [
                'appointment_id' => '1',
                'consultation_fee' => '200.00',
                'platform_fee' => '10.00',
                'transaction_fee' => '05.00',
                'tax' => '5',
                'tax_amount' => '10.00',
                'total_amount' => '235.00',
                'payment_status' => '1',
            ],
            2 => [
                'appointment_id' => '2',
                'consultation_fee' => '100.00',
                'platform_fee' => '10.00',
                'transaction_fee' => '05.00',
                'tax' => '5',
                'tax_amount' => '10.00',
                'total_amount' => '135.00',
                'payment_status' => '1',
            ],
            3 => [
                'appointment_id' => '3',
                'consultation_fee' => '150.00',
                'platform_fee' => '10.00',
                'transaction_fee' => '05.00',
                'tax' => '5',
                'tax_amount' => '10.00',
                'total_amount' => '185.00',
                'payment_status' => '1',
            ],
        ];

        foreach ($datas as $id => $data) {
            if ($id != 1) {
                //Tokbox Session ID and Token Generation
                /*$adminSetting = AdminSettings::take(1)->first();
                $tokboxApiKey = $adminSetting->tokbox_api_key;
                $tokboxSecret = $adminSetting->tokbox_secret;

                $openTok = new OpenTok($tokboxApiKey, $tokboxSecret);
                $sessionOptions = [
                    // 'archiveMode' => ArchiveMode::ALWAYS,
                    'mediaMode' => MediaMode::ROUTED,
                ];
                $tokenOptions = [
                    'role'       => Role::MODERATOR,
                    'expireTime' => time() + (30 * 24 * 60 * 60), // in one month
                ];
                $newSession = $openTok->createSession($sessionOptions);
                $tokboxSessionId = $newSession->getSessionId();
                $tokboxToken = $newSession->generateToken($tokenOptions);*/

                $data['tokbox_session_id'] = 'pending';
                $data['tokbox_token'] = 'pending';
            }

            Appointment::create($data);
        }

        foreach ($logDatas as $id => $data) {
            AppointmentLogs::create($data);
        }

        foreach ($reasonDatas as $id => $data) {
            AppointmentReason::create($data);
        }

        foreach ($symptomDatas as $id => $data) {
            AppointmentSymptom::create($data);
        }

        foreach ($paymentDatas as $id => $data) {
            Payment::create($data);
        }
    }
}