KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
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/leadai/webmaster.leadai.co.in/app/Exports/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/leadai/webmaster.leadai.co.in/app/Exports/RestaurantKeyExport.php
<?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 App\Models\User;
use App\Models\RestaurantKey;

class RestaurantKeyExport implements FromCollection, WithHeadings
{
	/**
	 * @return \Illuminate\Support\Collection
	 */
	public function collection()
	{

		$query = RestaurantKey::with("employee_details")->orderBy('created_at', 'DESC')->get(
			[
        "admin_id",
        "licence_key",
        "employee_id",
        "created_date",
        "activation_date",
        "duration",
        "status",
        "customer_id",
        "customer_name",
        "customer_email",
        "customer_mobile"
      ]);

      foreach($query as $q)
      {
         $q->employee_name = $q->employee_details ? $q->employee_details->name : "";
         $q->employee_mobile = $q->employee_details ? $q->employee_details->mobile : "";
         $q->employee_email = $q->employee_details ? $q->employee_details->email : "";
      }

      unset($query->employee_id);

      return $query;

	}

	public function headings(): array
	{
		return [
      "admin_id",
        "licence_key",
        "employee_id",
        "created_date",
        "activation_date",
        "duration",
        "status",
        "customer_id",
        "customer_name",
        "customer_email",
        "customer_mobile",
        "employee_name",
        "employee_mobile",
        "employee_email"
		];
	}
}

Anon7 - 2021