/home/mip/mip/public/vendor/laravel-filemanager/files/folder-1/821668/maatwebsite.zip
PK �8] �y($ $
excel/LICENSEnu �[��� MIT License
Copyright (c) Spartner
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
PK �8]*��0% % excel/src/Excel.phpnu �[��� <?php
namespace Maatwebsite\Excel;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\PendingDispatch;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Files\Filesystem;
use Maatwebsite\Excel\Files\TemporaryFile;
use Maatwebsite\Excel\Helpers\FileTypeDetector;
class Excel implements Exporter, Importer
{
use RegistersCustomConcerns;
const XLSX = 'Xlsx';
const CSV = 'Csv';
const TSV = 'Csv';
const ODS = 'Ods';
const XLS = 'Xls';
const SLK = 'Slk';
const XML = 'Xml';
const GNUMERIC = 'Gnumeric';
const HTML = 'Html';
const MPDF = 'Mpdf';
const DOMPDF = 'Dompdf';
const TCPDF = 'Tcpdf';
/**
* @var Writer
*/
protected $writer;
/**
* @var QueuedWriter
*/
protected $queuedWriter;
/**
* @var Filesystem
*/
protected $filesystem;
/**
* @var Reader
*/
private $reader;
/**
* @param Writer $writer
* @param QueuedWriter $queuedWriter
* @param Reader $reader
* @param Filesystem $filesystem
*/
public function __construct(
Writer $writer,
QueuedWriter $queuedWriter,
Reader $reader,
Filesystem $filesystem
) {
$this->writer = $writer;
$this->reader = $reader;
$this->filesystem = $filesystem;
$this->queuedWriter = $queuedWriter;
}
/**
* {@inheritdoc}
*/
public function download($export, string $fileName, string $writerType = null, array $headers = [])
{
// Clear output buffer to prevent stuff being prepended to the Excel output.
if (ob_get_length() > 0) {
ob_end_clean();
ob_start();
}
return response()->download(
$this->export($export, $fileName, $writerType)->getLocalPath(),
$fileName,
$headers
)->deleteFileAfterSend(true);
}
/**
* {@inheritdoc}
*
* @param string|null $disk Fallback for usage with named properties
*/
public function store($export, string $filePath, string $diskName = null, string $writerType = null, $diskOptions = [], string $disk = null)
{
if ($export instanceof ShouldQueue) {
return $this->queue($export, $filePath, $diskName ?: $disk, $writerType, $diskOptions);
}
$temporaryFile = $this->export($export, $filePath, $writerType);
$exported = $this->filesystem->disk($diskName ?: $disk, $diskOptions)->copy(
$temporaryFile,
$filePath
);
$temporaryFile->delete();
return $exported;
}
/**
* {@inheritdoc}
*/
public function queue($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
{
$writerType = FileTypeDetector::detectStrict($filePath, $writerType);
return $this->queuedWriter->store(
$export,
$filePath,
$disk,
$writerType,
$diskOptions
);
}
/**
* {@inheritdoc}
*/
public function raw($export, string $writerType)
{
$temporaryFile = $this->writer->export($export, $writerType);
$contents = $temporaryFile->contents();
$temporaryFile->delete();
return $contents;
}
/**
* {@inheritdoc}
*/
public function import($import, $filePath, string $disk = null, string $readerType = null)
{
$readerType = FileTypeDetector::detect($filePath, $readerType);
$response = $this->reader->read($import, $filePath, $readerType, $disk);
if ($response instanceof PendingDispatch) {
return $response;
}
return $this;
}
/**
* {@inheritdoc}
*/
public function toArray($import, $filePath, string $disk = null, string $readerType = null): array
{
$readerType = FileTypeDetector::detect($filePath, $readerType);
return $this->reader->toArray($import, $filePath, $readerType, $disk);
}
/**
* {@inheritdoc}
*/
public function toCollection($import, $filePath, string $disk = null, string $readerType = null): Collection
{
$readerType = FileTypeDetector::detect($filePath, $readerType);
return $this->reader->toCollection($import, $filePath, $readerType, $disk);
}
/**
* {@inheritdoc}
*/
public function queueImport(ShouldQueue $import, $filePath, string $disk = null, string $readerType = null)
{
return $this->import($import, $filePath, $disk, $readerType);
}
/**
* @param object $export
* @param string|null $fileName
* @param string $writerType
* @return TemporaryFile
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
protected function export($export, string $fileName, string $writerType = null): TemporaryFile
{
$writerType = FileTypeDetector::detectStrict($fileName, $writerType);
return $this->writer->export($export, $writerType);
}
}
PK �8]iam�� � excel/src/DelegatedMacroable.phpnu �[��� <?php
namespace Maatwebsite\Excel;
use Illuminate\Support\Traits\Macroable;
trait DelegatedMacroable
{
use Macroable {
__call as __callMacro;
}
/**
* Dynamically handle calls to the class.
*
* @param string $method
* @param array $parameters
* @return mixed
*/
public function __call($method, $parameters)
{
if (method_exists($this->getDelegate(), $method)) {
return call_user_func_array([$this->getDelegate(), $method], $parameters);
}
array_unshift($parameters, $this);
return $this->__callMacro($method, $parameters);
}
/**
* @return object
*/
abstract public function getDelegate();
}
PK �8]= z�� � % excel/src/Validators/RowValidator.phpnu �[��� <?php
namespace Maatwebsite\Excel\Validators;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException as IlluminateValidationException;
use Maatwebsite\Excel\Concerns\SkipsOnFailure;
use Maatwebsite\Excel\Concerns\WithValidation;
use Maatwebsite\Excel\Exceptions\RowSkippedException;
class RowValidator
{
/**
* @var Factory
*/
private $validator;
/**
* @param Factory $validator
*/
public function __construct(Factory $validator)
{
$this->validator = $validator;
}
/**
* @param array $rows
* @param WithValidation $import
*
* @throws ValidationException
* @throws RowSkippedException
*/
public function validate(array $rows, WithValidation $import)
{
$rules = $this->rules($import);
$messages = $this->messages($import);
$attributes = $this->attributes($import);
try {
$validator = $this->validator->make($rows, $rules, $messages, $attributes);
if (method_exists($import, 'withValidator')) {
$import->withValidator($validator);
}
$validator->validate();
} catch (IlluminateValidationException $e) {
$failures = [];
foreach ($e->errors() as $attribute => $messages) {
$row = strtok($attribute, '.');
$attributeName = strtok('');
$attributeName = $attributes['*.' . $attributeName] ?? $attributeName;
$failures[] = new Failure(
$row,
$attributeName,
str_replace($attribute, $attributeName, $messages),
$rows[$row] ?? []
);
}
if ($import instanceof SkipsOnFailure) {
$import->onFailure(...$failures);
throw new RowSkippedException(...$failures);
}
throw new ValidationException(
$e,
$failures
);
}
}
/**
* @param WithValidation $import
* @return array
*/
private function messages(WithValidation $import): array
{
return method_exists($import, 'customValidationMessages')
? $this->formatKey($import->customValidationMessages())
: [];
}
/**
* @param WithValidation $import
* @return array
*/
private function attributes(WithValidation $import): array
{
return method_exists($import, 'customValidationAttributes')
? $this->formatKey($import->customValidationAttributes())
: [];
}
/**
* @param WithValidation $import
* @return array
*/
private function rules(WithValidation $import): array
{
return $this->formatKey($import->rules());
}
/**
* @param array $elements
* @return array
*/
private function formatKey(array $elements): array
{
return collect($elements)->mapWithKeys(function ($rule, $attribute) {
$attribute = Str::startsWith($attribute, '*.') ? $attribute : '*.' . $attribute;
return [$attribute => $this->formatRule($rule)];
})->all();
}
/**
* @param string|object|callable|array $rules
* @return string|array
*/
private function formatRule($rules)
{
if (is_array($rules)) {
foreach ($rules as $rule) {
$formatted[] = $this->formatRule($rule);
}
return $formatted ?? [];
}
if (is_object($rules) || is_callable($rules)) {
return $rules;
}
if (Str::contains($rules, 'required_') && preg_match('/(.*?):(.*),(.*)/', $rules, $matches)) {
$column = Str::startsWith($matches[2], '*.') ? $matches[2] : '*.' . $matches[2];
return $matches[1] . ':' . $column . ',' . $matches[3];
}
return $rules;
}
}
PK �8]@�H6 6 excel/src/Validators/Failure.phpnu �[��� <?php
namespace Maatwebsite\Excel\Validators;
use Illuminate\Contracts\Support\Arrayable;
use JsonSerializable;
class Failure implements Arrayable, JsonSerializable
{
/**
* @var int
*/
protected $row;
/**
* @var string
*/
protected $attribute;
/**
* @var array
*/
protected $errors;
/**
* @var array
*/
private $values;
/**
* @param int $row
* @param string $attribute
* @param array $errors
* @param array $values
*/
public function __construct(int $row, string $attribute, array $errors, array $values = [])
{
$this->row = $row;
$this->attribute = $attribute;
$this->errors = $errors;
$this->values = $values;
}
/**
* @return int
*/
public function row(): int
{
return $this->row;
}
/**
* @return string
*/
public function attribute(): string
{
return $this->attribute;
}
/**
* @return array
*/
public function errors(): array
{
return $this->errors;
}
/**
* @return array
*/
public function values(): array
{
return $this->values;
}
/**
* @return array
*/
public function toArray()
{
return collect($this->errors)->map(function ($message) {
return __('There was an error on row :row. :message', ['row' => $this->row, 'message' => $message]);
})->all();
}
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
'row' => $this->row(),
'attribute' => $this->attribute(),
'errors' => $this->errors(),
'values' => $this->values(),
];
}
}
PK �8]��f f , excel/src/Validators/ValidationException.phpnu �[��� <?php
namespace Maatwebsite\Excel\Validators;
use Illuminate\Validation\ValidationException as IlluminateValidationException;
class ValidationException extends IlluminateValidationException
{
/**
* @var Failure[]
*/
protected $failures;
/**
* @param IlluminateValidationException $previous
* @param array $failures
*/
public function __construct(IlluminateValidationException $previous, array $failures)
{
parent::__construct($previous->validator, $previous->response, $previous->errorBag);
$this->failures = $failures;
}
/**
* @return string[]
*/
public function errors(): array
{
return collect($this->failures)->map->toArray()->all();
}
/**
* @return array
*/
public function failures(): array
{
return $this->failures;
}
}
PK �8]NE��) ) excel/src/Writer.phpnu �[��� <?php
namespace Maatwebsite\Excel;
use Illuminate\Support\Arr;
use Maatwebsite\Excel\Concerns\WithBackgroundColor;
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
use Maatwebsite\Excel\Concerns\WithDefaultStyles;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithProperties;
use Maatwebsite\Excel\Concerns\WithTitle;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\BeforeWriting;
use Maatwebsite\Excel\Factories\WriterFactory;
use Maatwebsite\Excel\Files\RemoteTemporaryFile;
use Maatwebsite\Excel\Files\TemporaryFile;
use Maatwebsite\Excel\Files\TemporaryFileFactory;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Style\Color;
use PhpOffice\PhpSpreadsheet\Style\Fill;
/** @mixin Spreadsheet */
class Writer
{
use DelegatedMacroable, HasEventBus;
/**
* @var Spreadsheet
*/
protected $spreadsheet;
/**
* @var object
*/
protected $exportable;
/**
* @var TemporaryFileFactory
*/
protected $temporaryFileFactory;
/**
* @param TemporaryFileFactory $temporaryFileFactory
*/
public function __construct(TemporaryFileFactory $temporaryFileFactory)
{
$this->temporaryFileFactory = $temporaryFileFactory;
$this->setDefaultValueBinder();
}
/**
* @param object $export
* @param string $writerType
* @return TemporaryFile
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function export($export, string $writerType): TemporaryFile
{
$this->open($export);
$sheetExports = [$export];
if ($export instanceof WithMultipleSheets) {
$sheetExports = $export->sheets();
}
foreach ($sheetExports as $sheetExport) {
$this->addNewSheet()->export($sheetExport);
}
return $this->write($export, $this->temporaryFileFactory->makeLocal(null, strtolower($writerType)), $writerType);
}
/**
* @param object $export
* @return $this
*/
public function open($export)
{
$this->exportable = $export;
if ($export instanceof WithEvents) {
$this->registerListeners($export->registerEvents());
}
$this->exportable = $export;
$this->spreadsheet = new Spreadsheet;
$this->spreadsheet->disconnectWorksheets();
if ($export instanceof WithCustomValueBinder) {
Cell::setValueBinder($export);
}
$this->handleDocumentProperties($export);
if ($export instanceof WithBackgroundColor) {
$defaultStyle = $this->spreadsheet->getDefaultStyle();
$backgroundColor = $export->backgroundColor();
if (is_string($backgroundColor)) {
$defaultStyle->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setRGB($backgroundColor);
}
if (is_array($backgroundColor)) {
$defaultStyle->applyFromArray(['fill' => $backgroundColor]);
}
if ($backgroundColor instanceof Color) {
$defaultStyle->getFill()->setFillType(Fill::FILL_SOLID)->setStartColor($backgroundColor);
}
}
if ($export instanceof WithDefaultStyles) {
$defaultStyle = $this->spreadsheet->getDefaultStyle();
$styles = $export->defaultStyles($defaultStyle);
if (is_array($styles)) {
$defaultStyle->applyFromArray($styles);
}
}
$this->raise(new BeforeExport($this, $this->exportable));
return $this;
}
/**
* @param TemporaryFile $tempFile
* @param string $writerType
* @return Writer
*
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function reopen(TemporaryFile $tempFile, string $writerType)
{
$reader = IOFactory::createReader($writerType);
$this->spreadsheet = $reader->load($tempFile->sync()->getLocalPath());
return $this;
}
/**
* @param object $export
* @param TemporaryFile $temporaryFile
* @param string $writerType
* @return TemporaryFile
*
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function write($export, TemporaryFile $temporaryFile, string $writerType): TemporaryFile
{
$this->exportable = $export;
$this->spreadsheet->setActiveSheetIndex(0);
$this->raise(new BeforeWriting($this, $this->exportable));
$writer = WriterFactory::make(
$writerType,
$this->spreadsheet,
$export
);
if ($temporaryFile instanceof RemoteTemporaryFile && !$temporaryFile->existsLocally()) {
$temporaryFile = resolve(TemporaryFileFactory::class)
->makeLocal(Arr::last(explode('/', $temporaryFile->getLocalPath())));
}
$writer->save(
$temporaryFile->getLocalPath()
);
if ($temporaryFile instanceof RemoteTemporaryFile) {
$temporaryFile->updateRemote();
$temporaryFile->deleteLocalCopy();
}
$this->clearListeners();
$this->spreadsheet->disconnectWorksheets();
unset($this->spreadsheet);
return $temporaryFile;
}
/**
* @param int|null $sheetIndex
* @return Sheet
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function addNewSheet(int $sheetIndex = null)
{
return new Sheet($this->spreadsheet->createSheet($sheetIndex));
}
/**
* @return Spreadsheet
*/
public function getDelegate()
{
return $this->spreadsheet;
}
/**
* @return $this
*/
public function setDefaultValueBinder()
{
Cell::setValueBinder(
app(config('excel.value_binder.default', DefaultValueBinder::class))
);
return $this;
}
/**
* @param int $sheetIndex
* @return Sheet
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
public function getSheetByIndex(int $sheetIndex)
{
return new Sheet($this->getDelegate()->getSheet($sheetIndex));
}
/**
* @param string $concern
* @return bool
*/
public function hasConcern($concern): bool
{
return $this->exportable instanceof $concern;
}
/**
* @param object $export
*/
protected function handleDocumentProperties($export)
{
$properties = config('excel.exports.properties', []);
if ($export instanceof WithProperties) {
$properties = array_merge($properties, $export->properties());
}
if ($export instanceof WithTitle) {
$properties = array_merge($properties, ['title' => $export->title()]);
}
$props = $this->spreadsheet->getProperties();
foreach (array_filter($properties) as $property => $value) {
switch ($property) {
case 'title':
$props->setTitle($value);
break;
case 'description':
$props->setDescription($value);
break;
case 'creator':
$props->setCreator($value);
break;
case 'lastModifiedBy':
$props->setLastModifiedBy($value);
break;
case 'subject':
$props->setSubject($value);
break;
case 'keywords':
$props->setKeywords($value);
break;
case 'category':
$props->setCategory($value);
break;
case 'manager':
$props->setManager($value);
break;
case 'company':
$props->setCompany($value);
break;
}
}
}
}
PK �8]�-�� � '