Anons79 Mini Shell

Directory : /home/aplikasiposinfo/www/bendahara2.aplikasipos.info/app/Exports/
Upload File :
Current File : /home/aplikasiposinfo/www/bendahara2.aplikasipos.info/app/Exports/transaksiExport.php

<?php

namespace App\Exports;

use App\Models\Transaksi;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Schema;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Style\Alignment;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;

class transaksiExport implements FromView, ShouldAutoSize, WithStyles
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function view(): View
    {
        //
        $data['anggaran_total'] = [];
        $data['anggaran'] = Transaksi::get();
        foreach($data['anggaran'] as $a) {
            $data['anggaran_total'][] = $a->anggaran->count();
        }
        $data['transaksi'] = Transaksi::join('anggarans', 'anggarans.transaksi_id', '=', 'transaksis.id')->get();
        // dd($data['transaksi']);
        return view('transaksi.export', $data);
    }

    public function styles(Worksheet $sheet)
    {
        $sheet->mergeCells('A1:A2');
        $sheet->mergeCells('I1:I2');
        $sheet->mergeCells('B1:H1');
        $sheet->mergeCells('B2:H2');
        $sheet->getStyle('B1:E1')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
        $sheet->getStyle('B1:E1')->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
        $sheet->getStyle('B2:E2')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
        $sheet->getStyle('B2:E2')->getAlignment()->setVertical(Alignment::VERTICAL_CENTER);
        $sheet->mergeCells('A4:I4');
        $sheet->getStyle('A4:I4')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);
        $sheet->mergeCells('A5:I5');
        $sheet->getStyle('A5:I5')->getAlignment()->setHorizontal(Alignment::HORIZONTAL_CENTER);

        $sapi = array("A","B","C","D","E","F", "G", "H", "I", "J", "K", "L", "M", "N", "O");

        foreach($sapi as $a) {
            $sheet->getStyle($a."7")->applyFromArray([
                'borders' => [
                    'allBorders' => [
                        'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                        'color' => ['argb' => '000000'],
                    ],
                ],
            ]);
            // $sheet->getStyle($a.'6')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('D9D9D9');
            $sheet->getStyle($a."6")->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
        }

        $no = 7;
        $data['transaksi'] = Transaksi::join('anggarans', 'anggarans.transaksi_id', '=', 'transaksis.id')->get();
        foreach($data['transaksi'] as $b) {

            // dd($b->transaksi);
            $no++;
            foreach($sapi as $a) {
                $sheet->getStyle($a.$no)->applyFromArray([
                    'borders' => [
                        'allBorders' => [
                            'borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN,
                            'color' => ['argb' => '000000'],
                        ],
                    ],
                ]);
                // $sheet->getStyle($a.$no)->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('D9D9D9');
                $sheet->getStyle($a.$no)->getAlignment()->setHorizontal(Alignment::HORIZONTAL_LEFT);
            }
        }
    }
}

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]