File "testExport.php"

Full Path: /var/www/html/back/app/Console/Commands/testExport.php
File size: 1.15 KB
MIME-type: text/x-php
Charset: utf-8

<?php

declare(strict_types=1);

namespace App\Console\Commands;

use App\Exports\PaymentsExport;
use App\Models\Payment;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;

class testExport extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'app:test-export';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     */
    public function handle(): void
    {
        //
        //        нужны такие поля:
        //
        //Дата	 	Название	Сумма	Контрагент	Проект	Статья	Заявитель	ID	Тип платежа	Счет
        //
        $ids = [1,2,3,4,5,6,7,8,9,10];
        $export = new PaymentsExport($payments = Payment::whereHas('distributions', function ($query) use ($ids): void {
            $query->whereIn('project_id', $ids);
        }), $ids);
        Excel::store($export, 'xxx/resultsx.xlsx', 'public');
        //file_put_contents('payments.xlsx', $f);
    }
}