CasperSecurity

Current Path : /var/www/hrms.uiet.co.in/app/Exports/
Upload File :
Current File : /var/www/hrms.uiet.co.in/app/Exports/IncidentReportExport.php

<?php

namespace App\Exports;

use App\Models\User;
use Carbon\Carbon;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;

class IncidentReportExport implements FromCollection, WithHeadings
{
    protected $reportData;
    protected $sl_no = 0;

    public function __construct($reportData)
    {
        $this->reportData = $reportData;
    }

    public function collection()
    {
        $reportData = [];
        foreach ($this->reportData as $key => $data) {
            $currentStatus = $raised_by = null;

            $raised_by = isset($data['raised_by'])
                ? $data['raised_by'] . (isset($data['incident_date'])
                    ? ' on ' . Carbon::parse($data['incident_date'])->format('j M Y')
                    : '')
                : 'NA';

            switch ($data['status']) {
                case 0:
                    $currentStatus = 'Inactive';
                    break;
                case 1:
                    $currentStatus = 'New';
                    break;
                case 2:
                    $currentStatus = 'Assigned';
                    break;
                case 3:
                    $currentStatus = 'Dev Fix';
                    break;
                case 4:
                    $currentStatus = 'Dev Verify';
                    break;
                case 5:
                    $currentStatus = 'Prod Deploy';
                    break;
                case 6:
                    $currentStatus = 'Prod Test';
                    break;
                default:
                    $currentStatus = 'Unknown';
                    break;
            }

            $selectedData = [
                'Sl No' => $key+1,
                'Project' => $data['getprojects']['project_name'] ?? 'N/A',
                'Client' => $data['client_name'] ?? 'N/A',
                'Raised By' => $raised_by,
                'Incident No.' => $data['defect_code'] ?? 'N/A',
                'Solution' => $data['defect_solution'] ?? 'N/A',
                'Current Status' => $currentStatus,
                'Dev Fix By' => optional(User::find($data['defect_dev_fix_owner']))->name ?? 'N/A',
                'Dev Fix Time' => $data['working_hour'] ?? 'N/A',
                'Dev Verify By' => optional(User::find($data['defect_dev_verify_owner']))->name ?? 'N/A',
                'Dev Verify Time' => $data['dev_verify_working_hour'] ?? 'N/A',
                'Prod Deploy By' => optional(User::find($data['defect_prod_deploy_owner']))->name ?? 'N/A',
                'Prod Deploy Time' => $data['prod_deploy_working_hour'] ?? 'N/A',
                'Prod Test By' => optional(User::find($data['defect_prod_test_owner']))->name ?? 'N/A',
                'Prod Test Time' => $data['prod_test_working_hour'] ?? 'N/A',

            ];

            $reportData[] = $selectedData;

        }

        return new Collection($reportData);
    }

    public function headings(): array
    {
        return array_keys($this->collection()->first());
    }

}
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY