|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/paras.theinteractive.in/app/Exports/ |
Upload File : |
<?php
namespace App\Exports;
use Illuminate\Support\Facades\DB;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\FromCollection;
use Illuminate\Support\Facades\Session;
use Maatwebsite\Excel\Concerns\FromArray;
class TempStudentExport implements FromArray, WithHeadings
{
private $start_date, $end_date;
public function __construct($from_date, $to_date)
{
$this->start_date = $from_date;
$this->end_date = $to_date;
}
public function array(): array
{
// Query
$students = DB::table('temp_admissions')
->whereDate('temp_admissions.created_at', '>=', $this->start_date)
->whereDate('temp_admissions.created_at', '<=', $this->end_date)
->leftJoin('users', function ($join) {
$join->on('users.email', '=', 'temp_admissions.email')
->orOn('users.phone', '=', 'temp_admissions.mobile_personal');
})
->leftJoin('users_admissions', 'users_admissions.user_unique_id', '=', 'users.user_unique_id')
->select(
"temp_admissions.id",
"users_admissions.id as new_roll_no",
"temp_admissions.course_class",
"temp_admissions.attempt",
"temp_admissions.adm_code",
"temp_admissions.code",
"temp_admissions.date",
"temp_admissions.aadhar_no",
"temp_admissions.ICAI_reg",
"temp_admissions.dob",
"temp_admissions.gender",
"temp_admissions.student_name",
"temp_admissions.father_name",
"temp_admissions.father_occupation",
"temp_admissions.mother_name",
"temp_admissions.address",
"temp_admissions.city",
"temp_admissions.state",
"temp_admissions.pincode",
"temp_admissions.village",
"temp_admissions.mobile_personal",
"temp_admissions.mobile_father",
"temp_admissions.mobile_guardian",
"temp_admissions.email",
"temp_admissions.school_last_attend",
"temp_admissions.subject_12th",
"temp_admissions.marks_10th",
"temp_admissions.expected_12th",
"temp_admissions.other",
"temp_admissions.medium_8th",
"temp_admissions.tenth",
"temp_admissions.class_12th",
"temp_admissions.medical_problem",
"temp_admissions.ca_in_family",
"temp_admissions.relative_name"
)->orderBy('temp_admissions.created_at', 'DESC')->get();
/*$query->orderBy('created_at', 'DESC');
$students = $query->get(
[
"id",
"course_class",
"attempt",
"adm_code",
"code",
"date",
"aadhar_no",
"ICAI_reg",
"dob",
"gender",
"profile_pic",
"student_name",
"father_name",
"father_occupation",
"mother_name",
"address",
"city",
"state",
"pincode",
"village",
"mobile_personal",
"mobile_father",
"mobile_guardian",
"email",
"school_last_attend",
"tution_account_teacher_name",
"tution_account_teacher_phone",
"school_account_teacher_name",
"school_account_teacher_phone",
"tution_math_teacher_name",
"tution_math_teacher_phone",
"school_math_teacher_name",
"school_math_teacher_phone",
"subject_12th",
"marks_10th",
"expected_12th",
"other",
"medium_8th",
"tenth",
"class_12th",
"medical_problem",
"ca_in_family",
"relative_name"
]
);*/
$collection = array();
foreach ($students as $student) {
array_push($collection, $student);
}
return $collection;
}
public function headings(): array
{
return [
"id",
"new_roll_no",
"course_class",
"attempt",
"adm_code",
"code",
"date",
"aadhar_no",
"ICAI_reg",
"dob",
"gender",
"student_name",
"father_name",
"father_occupation",
"mother_name",
"address",
"district",
"state",
"pincode",
"village",
"mobile_personal",
"mobile_father",
"mobile_guardian",
"email",
"school_last_attend",
"subject_12th",
"marks_10th",
"expected_12th",
"other",
"medium_8th",
"tenth",
"class_12th",
"medical_problem",
"ca_in_family",
"relative_name"
];
}
}