updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -0,0 +1,117 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Foundation\Bus\PendingDispatch;
use Maatwebsite\Excel\Exceptions\NoFilenameGivenException;
use Maatwebsite\Excel\Exceptions\NoFilePathGivenException;
use Maatwebsite\Excel\Exporter;
trait Exportable
{
/**
* @param string $fileName
* @param string|null $writerType
* @param array $headers
*
* @throws NoFilenameGivenException
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function download(string $fileName = null, string $writerType = null, array $headers = null)
{
$headers = $headers ?? $this->headers ?? [];
$fileName = $fileName ?? $this->fileName ?? null;
$writerType = $writerType ?? $this->writerType ?? null;
if (null === $fileName) {
throw new NoFilenameGivenException();
}
return $this->getExporter()->download($this, $fileName, $writerType, $headers);
}
/**
* @param string $filePath
* @param string|null $disk
* @param string|null $writerType
* @param mixed $diskOptions
*
* @throws NoFilePathGivenException
* @return bool|PendingDispatch
*/
public function store(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
{
$filePath = $filePath ?? $this->filePath ?? null;
if (null === $filePath) {
throw NoFilePathGivenException::export();
}
return $this->getExporter()->store(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$writerType ?? $this->writerType ?? null,
$diskOptions ?? $this->diskOptions ?? []
);
}
/**
* @param string|null $filePath
* @param string|null $disk
* @param string|null $writerType
* @param mixed $diskOptions
*
* @throws NoFilePathGivenException
* @return PendingDispatch
*/
public function queue(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
{
$filePath = $filePath ?? $this->filePath ?? null;
if (null === $filePath) {
throw NoFilePathGivenException::export();
}
return $this->getExporter()->queue(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$writerType ?? $this->writerType ?? null,
$diskOptions ?? $this->diskOptions ?? []
);
}
/**
* @param string|null $writerType
*
* @return string
*/
public function raw($writerType = null)
{
$writerType = $writerType ?? $this->writerType ?? null;
return $this->getExporter()->raw($this, $writerType);
}
/**
* Create an HTTP response that represents the object.
*
* @param \Illuminate\Http\Request $request
*
* @throws NoFilenameGivenException
* @return \Illuminate\Http\Response
*/
public function toResponse($request)
{
return $this->download();
}
/**
* @return Exporter
*/
private function getExporter(): Exporter
{
return app(Exporter::class);
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface FromArray
{
/**
* @return array
*/
public function array(): array;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
interface FromCollection
{
/**
* @return Collection
*/
public function collection();
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Generator;
interface FromGenerator
{
/**
* @return Generator
*/
public function generator(): Generator;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Iterator;
interface FromIterator
{
/**
* @return Iterator
*/
public function iterator(): Iterator;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Database\Query\Builder;
interface FromQuery
{
/**
* @return Builder
*/
public function query();
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Contracts\View\View;
interface FromView
{
/**
* @return View
*/
public function view(): View;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface HasReferencesToOtherSheets
{
}

View File

@@ -0,0 +1,149 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Console\OutputStyle;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\PendingDispatch;
use Illuminate\Support\Collection;
use InvalidArgumentException;
use Maatwebsite\Excel\Exceptions\NoFilePathGivenException;
use Maatwebsite\Excel\Importer;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\HttpFoundation\File\UploadedFile;
trait Importable
{
/**
* @var OutputStyle|null
*/
protected $output;
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
*
* @throws NoFilePathGivenException
* @return Importer|PendingDispatch
*/
public function import($filePath = null, string $disk = null, string $readerType = null)
{
$filePath = $this->getFilePath($filePath);
return $this->getImporter()->import(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$readerType ?? $this->readerType ?? null
);
}
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
*
* @throws NoFilePathGivenException
* @return array
*/
public function toArray($filePath = null, string $disk = null, string $readerType = null): array
{
$filePath = $this->getFilePath($filePath);
return $this->getImporter()->toArray(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$readerType ?? $this->readerType ?? null
);
}
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
*
* @throws NoFilePathGivenException
* @return Collection
*/
public function toCollection($filePath = null, string $disk = null, string $readerType = null): Collection
{
$filePath = $this->getFilePath($filePath);
return $this->getImporter()->toCollection(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$readerType ?? $this->readerType ?? null
);
}
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
*
* @throws NoFilePathGivenException
* @throws InvalidArgumentException
* @return PendingDispatch
*/
public function queue($filePath = null, string $disk = null, string $readerType = null)
{
if (!$this instanceof ShouldQueue) {
throw new InvalidArgumentException('Importable should implement ShouldQueue to be queued.');
}
return $this->import($filePath, $disk, $readerType);
}
/**
* @param OutputStyle $output
*
* @return $this
*/
public function withOutput(OutputStyle $output)
{
$this->output = $output;
return $this;
}
/**
* @return OutputStyle
*/
public function getConsoleOutput(): OutputStyle
{
if (!$this->output instanceof OutputStyle) {
$this->output = new OutputStyle(new StringInput(''), new NullOutput());
}
return $this->output;
}
/**
* @param UploadedFile|string|null $filePath
*
* @throws NoFilePathGivenException
* @return UploadedFile|string
*/
private function getFilePath($filePath = null)
{
$filePath = $filePath ?? $this->filePath ?? null;
if (null === $filePath) {
throw NoFilePathGivenException::import();
}
return $filePath;
}
/**
* @return Importer
*/
private function getImporter(): Importer
{
return app(Importer::class);
}
}

View File

@@ -0,0 +1,69 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Arr;
trait MapsCsvSettings
{
/**
* @var string
*/
protected static $delimiter = ',';
/**
* @var string
*/
protected static $enclosure = '"';
/**
* @var string
*/
protected static $lineEnding = PHP_EOL;
/**
* @var bool
*/
protected static $useBom = false;
/**
* @var bool
*/
protected static $includeSeparatorLine = false;
/**
* @var bool
*/
protected static $excelCompatibility = false;
/**
* @var string
*/
protected static $escapeCharacter = '\\';
/**
* @var bool
*/
protected static $contiguous = false;
/**
* @var string
*/
protected static $inputEncoding = 'UTF-8';
/**
* @param array $config
*/
public static function applyCsvSettings(array $config)
{
static::$delimiter = Arr::get($config, 'delimiter', static::$delimiter);
static::$enclosure = Arr::get($config, 'enclosure', static::$enclosure);
static::$lineEnding = Arr::get($config, 'line_ending', static::$lineEnding);
static::$useBom = Arr::get($config, 'use_bom', static::$useBom);
static::$includeSeparatorLine = Arr::get($config, 'include_separator_line', static::$includeSeparatorLine);
static::$excelCompatibility = Arr::get($config, 'excel_compatibility', static::$excelCompatibility);
static::$escapeCharacter = Arr::get($config, 'escape_character', static::$escapeCharacter);
static::$contiguous = Arr::get($config, 'contiguous', static::$contiguous);
static::$inputEncoding = Arr::get($config, 'input_encoding', static::$inputEncoding);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Maatwebsite\Excel\Row;
interface OnEachRow
{
/**
* @param Row $row
*/
public function onRow(Row $row);
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Maatwebsite\Excel\Events\AfterImport;
use Maatwebsite\Excel\Events\AfterSheet;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\BeforeImport;
use Maatwebsite\Excel\Events\BeforeSheet;
use Maatwebsite\Excel\Events\BeforeWriting;
use Maatwebsite\Excel\Events\ImportFailed;
trait RegistersEventListeners
{
/**
* @return array
*/
public function registerEvents(): array
{
$listeners = [];
if (method_exists($this, 'beforeExport')) {
$listeners[BeforeExport::class] = [static::class, 'beforeExport'];
}
if (method_exists($this, 'beforeWriting')) {
$listeners[BeforeWriting::class] = [static::class, 'beforeWriting'];
}
if (method_exists($this, 'beforeImport')) {
$listeners[BeforeImport::class] = [static::class, 'beforeImport'];
}
if (method_exists($this, 'afterImport')) {
$listeners[AfterImport::class] = [static::class, 'afterImport'];
}
if (method_exists($this, 'importFailed')) {
$listeners[ImportFailed::class] = [static::class, 'importFailed'];
}
if (method_exists($this, 'beforeSheet')) {
$listeners[BeforeSheet::class] = [static::class, 'beforeSheet'];
}
if (method_exists($this, 'afterSheet')) {
$listeners[AfterSheet::class] = [static::class, 'afterSheet'];
}
return $listeners;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Maatwebsite\Excel\Concerns;
trait RemembersChunkOffset
{
/**
* @var int|null
*/
protected $chunkOffset;
/**
* @param int $chunkOffset
*/
public function setChunkOffset(int $chunkOffset)
{
$this->chunkOffset = $chunkOffset;
}
/**
* @return int|null
*/
public function getChunkOffset()
{
return $this->chunkOffset;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace Maatwebsite\Excel\Concerns;
trait RemembersRowNumber
{
/**
* @var int
*/
protected $rowNumber;
/**
* @param int $rowNumber
*/
public function rememberRowNumber(int $rowNumber)
{
$this->rowNumber = $rowNumber;
}
/**
* @return int|null
*/
public function getRowNumber()
{
return $this->rowNumber;
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface ShouldAutoSize
{
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Contracts\Queue\ShouldQueue;
interface ShouldQueueWithoutChain extends ShouldQueue
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface SkipsEmptyRows
{
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
use Throwable;
trait SkipsErrors
{
/**
* @var Throwable[]
*/
protected $errors = [];
/**
* @param Throwable $e
*/
public function onError(Throwable $e)
{
$this->errors[] = $e;
}
/**
* @return Throwable[]|Collection
*/
public function errors(): Collection
{
return new Collection($this->errors);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Validators\Failure;
trait SkipsFailures
{
/**
* @var Failure[]
*/
protected $failures = [];
/**
* @param Failure ...$failures
*/
public function onFailure(Failure ...$failures)
{
$this->failures = array_merge($this->failures, $failures);
}
/**
* @return Failure[]|Collection
*/
public function failures(): Collection
{
return new Collection($this->failures);
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Throwable;
interface SkipsOnError
{
/**
* @param Throwable $e
*/
public function onError(Throwable $e);
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Maatwebsite\Excel\Validators\Failure;
interface SkipsOnFailure
{
/**
* @param Failure[] $failures
*/
public function onFailure(Failure ...$failures);
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface SkipsUnknownSheets
{
/**
* @param string|int $sheetName
*/
public function onUnknownSheet($sheetName);
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface ToArray
{
/**
* @param array $array
*/
public function array(array $array);
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
interface ToCollection
{
/**
* @param Collection $collection
*/
public function collection(Collection $collection);
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Database\Eloquent\Model;
interface ToModel
{
/**
* @param array $row
*
* @return Model|Model[]|null
*/
public function model(array $row);
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithBatchInserts
{
/**
* @return int
*/
public function batchSize(): int;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithCalculatedFormulas
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Chart\Chart;
interface WithCharts
{
/**
* @return Chart|Chart[]
*/
public function charts();
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithChunkReading
{
/**
* @return int
*/
public function chunkSize(): int;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithColumnFormatting
{
/**
* @return array
*/
public function columnFormats(): array;
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithColumnLimit
{
public function endColumn(): string;
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithColumnWidths
{
public function columnWidths(): array;
}

View File

@@ -0,0 +1,38 @@
<?php
namespace Maatwebsite\Excel\Concerns;
trait WithConditionalSheets
{
/**
* @var array
*/
protected $conditionallySelectedSheets = [];
/**
* @param string|array $sheets
*
* @return $this
*/
public function onlySheets($sheets)
{
$this->conditionallySelectedSheets = is_array($sheets) ? $sheets : func_get_args();
return $this;
}
/**
* @return array
*/
public function sheets(): array
{
return \array_filter($this->conditionalSheets(), function ($name) {
return \in_array($name, $this->conditionallySelectedSheets, false);
}, ARRAY_FILTER_USE_KEY);
}
/**
* @return array
*/
abstract public function conditionalSheets(): array;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomChunkSize
{
/**
* @return int
*/
public function chunkSize(): int;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomCsvSettings
{
/**
* @return array
*/
public function getCsvSettings(): array;
}

View File

@@ -0,0 +1,17 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomQuerySize
{
/**
* Queued exportables are processed in chunks; each chunk being a job pushed to the queue by the QueuedWriter.
* In case of exportables that implement the FromQuery concern, the number of jobs is calculated by dividing the $query->count() by the chunk size.
* Depending on the implementation of the query() method (eg. When using a groupBy clause), this calculation might not be correct.
*
* When this is the case, you should use this method to provide a custom calculation of the query size.
*
* @return int
*/
public function querySize(): int;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomStartCell
{
/**
* @return string
*/
public function startCell(): string;
}

View File

@@ -0,0 +1,9 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
interface WithCustomValueBinder extends IValueBinder
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing;
interface WithDrawings
{
/**
* @return BaseDrawing|BaseDrawing[]
*/
public function drawings();
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithEvents
{
/**
* @return array
*/
public function registerEvents(): array;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithFormatData
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithHeadingRow
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithHeadings
{
/**
* @return array
*/
public function headings(): array;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithLimit
{
/**
* @return int
*/
public function limit(): int;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithMappedCells
{
/**
* @return array
*/
public function mapping(): array;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithMapping
{
/**
* @param mixed $row
*
* @return array
*/
public function map($row): array;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithMultipleSheets
{
/**
* @return array
*/
public function sheets(): array;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithPreCalculateFormulas
{
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Console\OutputStyle;
interface WithProgressBar
{
/**
* @return OutputStyle
*/
public function getConsoleOutput(): OutputStyle;
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithProperties
{
public function properties(): array;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
interface WithReadFilter
{
/**
* @return IReadFilter
*/
public function readFilter(): IReadFilter;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithStartRow
{
/**
* @return int
*/
public function startRow(): int;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithStrictNullComparison
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
interface WithStyles
{
public function styles(Worksheet $sheet);
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithTitle
{
/**
* @return string
*/
public function title(): string;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithUpsertColumns
{
/**
* @return array
*/
public function upsertColumns();
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithUpserts
{
/**
* @return string|array
*/
public function uniqueBy();
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Maatwebsite\Excel\Concerns;
interface WithValidation
{
/**
* @return array
*/
public function rules(): array;
}