package and depencies
This commit is contained in:
@@ -17,8 +17,8 @@ class BatchCache implements CacheInterface
|
||||
protected $memory;
|
||||
|
||||
/**
|
||||
* @param CacheInterface $cache
|
||||
* @param MemoryCache $memory
|
||||
* @param CacheInterface $cache
|
||||
* @param MemoryCache $memory
|
||||
*/
|
||||
public function __construct(CacheInterface $cache, MemoryCache $memory)
|
||||
{
|
||||
@@ -29,7 +29,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
public function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
if ($this->memory->has($key)) {
|
||||
return $this->memory->get($key);
|
||||
@@ -41,7 +41,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
|
||||
{
|
||||
$this->memory->set($key, $value, $ttl);
|
||||
|
||||
@@ -55,7 +55,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($key)
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
if ($this->memory->has($key)) {
|
||||
return $this->memory->delete($key);
|
||||
@@ -67,7 +67,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): bool
|
||||
{
|
||||
$this->memory->clear();
|
||||
|
||||
@@ -77,7 +77,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
public function getMultiple(iterable $keys, mixed $default = null): iterable
|
||||
{
|
||||
// Check if all keys are still in memory
|
||||
$memory = $this->memory->getMultiple($keys, $default);
|
||||
@@ -105,7 +105,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
public function setMultiple(iterable $values, null|int|\DateInterval $ttl = null): bool
|
||||
{
|
||||
$this->memory->setMultiple($values, $ttl);
|
||||
|
||||
@@ -119,7 +119,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
public function deleteMultiple(iterable $keys): bool
|
||||
{
|
||||
$keys = is_array($keys) ? $keys : iterator_to_array($keys);
|
||||
|
||||
@@ -131,7 +131,7 @@ class BatchCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($key)
|
||||
public function has(string $key): bool
|
||||
{
|
||||
if ($this->memory->has($key)) {
|
||||
return true;
|
||||
|
142
vendor/maatwebsite/excel/src/Cache/BatchCacheDeprecated.php
vendored
Normal file
142
vendor/maatwebsite/excel/src/Cache/BatchCacheDeprecated.php
vendored
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Cache;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
class BatchCacheDeprecated implements CacheInterface
|
||||
{
|
||||
/**
|
||||
* @var CacheInterface
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* @var MemoryCacheDeprecated
|
||||
*/
|
||||
protected $memory;
|
||||
|
||||
/**
|
||||
* @param CacheInterface $cache
|
||||
* @param MemoryCacheDeprecated $memory
|
||||
*/
|
||||
public function __construct(CacheInterface $cache, MemoryCacheDeprecated $memory)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->memory = $memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if ($this->memory->has($key)) {
|
||||
return $this->memory->get($key);
|
||||
}
|
||||
|
||||
return $this->cache->get($key, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
$this->memory->set($key, $value, $ttl);
|
||||
|
||||
if ($this->memory->reachedMemoryLimit()) {
|
||||
return $this->cache->setMultiple($this->memory->flush(), $ttl);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
if ($this->memory->has($key)) {
|
||||
return $this->memory->delete($key);
|
||||
}
|
||||
|
||||
return $this->cache->delete($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->memory->clear();
|
||||
|
||||
return $this->cache->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
{
|
||||
// Check if all keys are still in memory
|
||||
$memory = $this->memory->getMultiple($keys, $default);
|
||||
$actualItemsInMemory = count(array_filter($memory));
|
||||
|
||||
if ($actualItemsInMemory === count($keys)) {
|
||||
return $memory;
|
||||
}
|
||||
|
||||
// Get all rows from cache if none is hold in memory.
|
||||
if ($actualItemsInMemory === 0) {
|
||||
return $this->cache->getMultiple($keys, $default);
|
||||
}
|
||||
|
||||
// Add missing values from cache.
|
||||
foreach ($this->cache->getMultiple($keys, $default) as $key => $value) {
|
||||
if (null !== $value) {
|
||||
$memory[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $memory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
$this->memory->setMultiple($values, $ttl);
|
||||
|
||||
if ($this->memory->reachedMemoryLimit()) {
|
||||
return $this->cache->setMultiple($this->memory->flush(), $ttl);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
{
|
||||
$keys = is_array($keys) ? $keys : iterator_to_array($keys);
|
||||
|
||||
$this->memory->deleteMultiple($keys);
|
||||
|
||||
return $this->cache->deleteMultiple($keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
if ($this->memory->has($key)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->cache->has($key);
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Maatwebsite\Excel\Cache;
|
||||
|
||||
use Composer\InstalledVersions;
|
||||
use Composer\Semver\VersionParser;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Manager;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
@@ -38,6 +40,12 @@ class CacheManager extends Manager
|
||||
*/
|
||||
public function createMemoryDriver(): CacheInterface
|
||||
{
|
||||
if (!InstalledVersions::satisfies(new VersionParser, 'psr/simple-cache', '^3.0')) {
|
||||
return new MemoryCacheDeprecated(
|
||||
config('excel.cache.batch.memory_limit', 60000)
|
||||
);
|
||||
}
|
||||
|
||||
return new MemoryCache(
|
||||
config('excel.cache.batch.memory_limit', 60000)
|
||||
);
|
||||
@@ -48,6 +56,13 @@ class CacheManager extends Manager
|
||||
*/
|
||||
public function createBatchDriver(): CacheInterface
|
||||
{
|
||||
if (!InstalledVersions::satisfies(new VersionParser, 'psr/simple-cache', '^3.0')) {
|
||||
return new BatchCacheDeprecated(
|
||||
$this->createIlluminateDriver(),
|
||||
$this->createMemoryDriver()
|
||||
);
|
||||
}
|
||||
|
||||
return new BatchCache(
|
||||
$this->createIlluminateDriver(),
|
||||
$this->createMemoryDriver()
|
||||
|
@@ -17,7 +17,7 @@ class MemoryCache implements CacheInterface
|
||||
protected $cache = [];
|
||||
|
||||
/**
|
||||
* @param int|null $memoryLimit
|
||||
* @param int|null $memoryLimit
|
||||
*/
|
||||
public function __construct(int $memoryLimit = null)
|
||||
{
|
||||
@@ -27,7 +27,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
public function clear(): bool
|
||||
{
|
||||
$this->cache = [];
|
||||
|
||||
@@ -37,7 +37,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($key)
|
||||
public function delete(string $key): bool
|
||||
{
|
||||
unset($this->cache[$key]);
|
||||
|
||||
@@ -47,7 +47,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
public function deleteMultiple($keys): bool
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$this->delete($key);
|
||||
@@ -59,7 +59,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
public function get(string $key, mixed $default = null): mixed
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
return $this->cache[$key];
|
||||
@@ -71,7 +71,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
public function getMultiple(iterable $keys, mixed $default = null): iterable
|
||||
{
|
||||
$results = [];
|
||||
foreach ($keys as $key) {
|
||||
@@ -84,7 +84,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($key)
|
||||
public function has($key): bool
|
||||
{
|
||||
return isset($this->cache[$key]);
|
||||
}
|
||||
@@ -92,7 +92,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
|
||||
{
|
||||
$this->cache[$key] = $value;
|
||||
|
||||
@@ -102,7 +102,7 @@ class MemoryCache implements CacheInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
public function setMultiple($values, $ttl = null): bool
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
$this->set($key, $value);
|
||||
|
138
vendor/maatwebsite/excel/src/Cache/MemoryCacheDeprecated.php
vendored
Normal file
138
vendor/maatwebsite/excel/src/Cache/MemoryCacheDeprecated.php
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Cache;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
|
||||
class MemoryCacheDeprecated implements CacheInterface
|
||||
{
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
protected $memoryLimit;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $cache = [];
|
||||
|
||||
/**
|
||||
* @param int|null $memoryLimit
|
||||
*/
|
||||
public function __construct(int $memoryLimit = null)
|
||||
{
|
||||
$this->memoryLimit = $memoryLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function clear()
|
||||
{
|
||||
$this->cache = [];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
unset($this->cache[$key]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMultiple($keys)
|
||||
{
|
||||
foreach ($keys as $key) {
|
||||
$this->delete($key);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($key, $default = null)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
return $this->cache[$key];
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMultiple($keys, $default = null)
|
||||
{
|
||||
$results = [];
|
||||
foreach ($keys as $key) {
|
||||
$results[$key] = $this->get($key, $default);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function has($key)
|
||||
{
|
||||
return isset($this->cache[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($key, $value, $ttl = null)
|
||||
{
|
||||
$this->cache[$key] = $value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setMultiple($values, $ttl = null)
|
||||
{
|
||||
foreach ($values as $key => $value) {
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function reachedMemoryLimit(): bool
|
||||
{
|
||||
// When no limit is given, we'll never reach any limit.
|
||||
if (null === $this->memoryLimit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return count($this->cache) >= $this->memoryLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function flush(): array
|
||||
{
|
||||
$memory = $this->cache;
|
||||
|
||||
$this->clear();
|
||||
|
||||
return $memory;
|
||||
}
|
||||
}
|
16
vendor/maatwebsite/excel/src/Cell.php
vendored
16
vendor/maatwebsite/excel/src/Cell.php
vendored
@@ -8,6 +8,7 @@ use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
/** @mixin SpreadsheetCell */
|
||||
class Cell
|
||||
{
|
||||
use DelegatedMacroable;
|
||||
@@ -18,7 +19,7 @@ class Cell
|
||||
private $cell;
|
||||
|
||||
/**
|
||||
* @param SpreadsheetCell $cell
|
||||
* @param SpreadsheetCell $cell
|
||||
*/
|
||||
public function __construct(SpreadsheetCell $cell)
|
||||
{
|
||||
@@ -26,11 +27,11 @@ class Cell
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Worksheet $worksheet
|
||||
* @param string $coordinate
|
||||
* @param Worksheet $worksheet
|
||||
* @param string $coordinate
|
||||
* @return Cell
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @return Cell
|
||||
*/
|
||||
public static function make(Worksheet $worksheet, string $coordinate)
|
||||
{
|
||||
@@ -46,10 +47,9 @@ class Cell
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
*
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
* @return mixed
|
||||
*/
|
||||
public function getValue($nullValue = null, $calculateFormulas = false, $formatData = true)
|
||||
|
7
vendor/maatwebsite/excel/src/ChunkReader.php
vendored
7
vendor/maatwebsite/excel/src/ChunkReader.php
vendored
@@ -21,10 +21,9 @@ use Throwable;
|
||||
class ChunkReader
|
||||
{
|
||||
/**
|
||||
* @param WithChunkReading $import
|
||||
* @param Reader $reader
|
||||
* @param TemporaryFile $temporaryFile
|
||||
*
|
||||
* @param WithChunkReading $import
|
||||
* @param Reader $reader
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @return \Illuminate\Foundation\Bus\PendingDispatch|null
|
||||
*/
|
||||
public function read(WithChunkReading $import, Reader $reader, TemporaryFile $temporaryFile)
|
||||
|
@@ -10,12 +10,12 @@ use Maatwebsite\Excel\Exporter;
|
||||
trait Exportable
|
||||
{
|
||||
/**
|
||||
* @param string $fileName
|
||||
* @param string|null $writerType
|
||||
* @param array $headers
|
||||
* @param string $fileName
|
||||
* @param string|null $writerType
|
||||
* @param array $headers
|
||||
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*
|
||||
* @throws NoFilenameGivenException
|
||||
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*/
|
||||
public function download(string $fileName = null, string $writerType = null, array $headers = null)
|
||||
{
|
||||
@@ -31,13 +31,13 @@ trait Exportable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @return bool|PendingDispatch
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @return bool|PendingDispatch
|
||||
*/
|
||||
public function store(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
|
||||
{
|
||||
@@ -52,18 +52,18 @@ trait Exportable
|
||||
$filePath,
|
||||
$disk ?? $this->disk ?? null,
|
||||
$writerType ?? $this->writerType ?? null,
|
||||
$diskOptions ?? $this->diskOptions ?? []
|
||||
$diskOptions ?: $this->diskOptions ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @param string|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @return PendingDispatch
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @return PendingDispatch
|
||||
*/
|
||||
public function queue(string $filePath = null, string $disk = null, string $writerType = null, $diskOptions = [])
|
||||
{
|
||||
@@ -78,13 +78,12 @@ trait Exportable
|
||||
$filePath,
|
||||
$disk ?? $this->disk ?? null,
|
||||
$writerType ?? $this->writerType ?? null,
|
||||
$diskOptions ?? $this->diskOptions ?? []
|
||||
$diskOptions ?: $this->diskOptions ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $writerType
|
||||
*
|
||||
* @param string|null $writerType
|
||||
* @return string
|
||||
*/
|
||||
public function raw($writerType = null)
|
||||
@@ -97,10 +96,10 @@ trait Exportable
|
||||
/**
|
||||
* Create an HTTP response that represents the object.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @throws NoFilenameGivenException
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function toResponse($request)
|
||||
{
|
||||
|
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace Maatwebsite\Excel\Concerns;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
|
||||
interface FromQuery
|
||||
{
|
||||
/**
|
||||
* @return Builder
|
||||
* @return Builder|EloquentBuilder|Relation
|
||||
*/
|
||||
public function query();
|
||||
}
|
||||
|
@@ -21,12 +21,12 @@ trait Importable
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return Importer|PendingDispatch
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @return Importer|PendingDispatch
|
||||
*/
|
||||
public function import($filePath = null, string $disk = null, string $readerType = null)
|
||||
{
|
||||
@@ -41,12 +41,12 @@ trait Importable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return array
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($filePath = null, string $disk = null, string $readerType = null): array
|
||||
{
|
||||
@@ -61,12 +61,12 @@ trait Importable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return Collection
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @return Collection
|
||||
*/
|
||||
public function toCollection($filePath = null, string $disk = null, string $readerType = null): Collection
|
||||
{
|
||||
@@ -81,13 +81,13 @@ trait Importable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @param string|UploadedFile|null $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return PendingDispatch
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @throws InvalidArgumentException
|
||||
* @return PendingDispatch
|
||||
*/
|
||||
public function queue($filePath = null, string $disk = null, string $readerType = null)
|
||||
{
|
||||
@@ -99,8 +99,7 @@ trait Importable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OutputStyle $output
|
||||
*
|
||||
* @param OutputStyle $output
|
||||
* @return $this
|
||||
*/
|
||||
public function withOutput(OutputStyle $output)
|
||||
@@ -123,10 +122,10 @@ trait Importable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UploadedFile|string|null $filePath
|
||||
* @param UploadedFile|string|null $filePath
|
||||
* @return UploadedFile|string
|
||||
*
|
||||
* @throws NoFilePathGivenException
|
||||
* @return UploadedFile|string
|
||||
*/
|
||||
private function getFilePath($filePath = null)
|
||||
{
|
||||
|
@@ -52,7 +52,17 @@ trait MapsCsvSettings
|
||||
protected static $inputEncoding = 'UTF-8';
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
* @var string
|
||||
*/
|
||||
protected static $outputEncoding = '';
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected static $testAutoDetect = true;
|
||||
|
||||
/**
|
||||
* @param array $config
|
||||
*/
|
||||
public static function applyCsvSettings(array $config)
|
||||
{
|
||||
@@ -65,5 +75,7 @@ trait MapsCsvSettings
|
||||
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);
|
||||
static::$outputEncoding = Arr::get($config, 'output_encoding', static::$outputEncoding);
|
||||
static::$testAutoDetect = Arr::get($config, 'test_auto_detect', static::$testAutoDetect);
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ use Maatwebsite\Excel\Row;
|
||||
interface OnEachRow
|
||||
{
|
||||
/**
|
||||
* @param Row $row
|
||||
* @param Row $row
|
||||
*/
|
||||
public function onRow(Row $row);
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ trait RemembersChunkOffset
|
||||
protected $chunkOffset;
|
||||
|
||||
/**
|
||||
* @param int $chunkOffset
|
||||
* @param int $chunkOffset
|
||||
*/
|
||||
public function setChunkOffset(int $chunkOffset)
|
||||
{
|
||||
|
@@ -10,7 +10,7 @@ trait RemembersRowNumber
|
||||
protected $rowNumber;
|
||||
|
||||
/**
|
||||
* @param int $rowNumber
|
||||
* @param int $rowNumber
|
||||
*/
|
||||
public function rememberRowNumber(int $rowNumber)
|
||||
{
|
||||
|
@@ -13,7 +13,7 @@ trait SkipsErrors
|
||||
protected $errors = [];
|
||||
|
||||
/**
|
||||
* @param Throwable $e
|
||||
* @param Throwable $e
|
||||
*/
|
||||
public function onError(Throwable $e)
|
||||
{
|
||||
|
@@ -13,7 +13,7 @@ trait SkipsFailures
|
||||
protected $failures = [];
|
||||
|
||||
/**
|
||||
* @param Failure ...$failures
|
||||
* @param Failure ...$failures
|
||||
*/
|
||||
public function onFailure(Failure ...$failures)
|
||||
{
|
||||
|
@@ -7,7 +7,7 @@ use Throwable;
|
||||
interface SkipsOnError
|
||||
{
|
||||
/**
|
||||
* @param Throwable $e
|
||||
* @param Throwable $e
|
||||
*/
|
||||
public function onError(Throwable $e);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ use Maatwebsite\Excel\Validators\Failure;
|
||||
interface SkipsOnFailure
|
||||
{
|
||||
/**
|
||||
* @param Failure[] $failures
|
||||
* @param Failure[] $failures
|
||||
*/
|
||||
public function onFailure(Failure ...$failures);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ namespace Maatwebsite\Excel\Concerns;
|
||||
interface SkipsUnknownSheets
|
||||
{
|
||||
/**
|
||||
* @param string|int $sheetName
|
||||
* @param string|int $sheetName
|
||||
*/
|
||||
public function onUnknownSheet($sheetName);
|
||||
}
|
||||
|
@@ -5,7 +5,7 @@ namespace Maatwebsite\Excel\Concerns;
|
||||
interface ToArray
|
||||
{
|
||||
/**
|
||||
* @param array $array
|
||||
* @param array $array
|
||||
*/
|
||||
public function array(array $array);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ use Illuminate\Support\Collection;
|
||||
interface ToCollection
|
||||
{
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function collection(Collection $collection);
|
||||
}
|
||||
|
@@ -7,8 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
interface ToModel
|
||||
{
|
||||
/**
|
||||
* @param array $row
|
||||
*
|
||||
* @param array $row
|
||||
* @return Model|Model[]|null
|
||||
*/
|
||||
public function model(array $row);
|
||||
|
13
vendor/maatwebsite/excel/src/Concerns/WithBackgroundColor.php
vendored
Normal file
13
vendor/maatwebsite/excel/src/Concerns/WithBackgroundColor.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Concerns;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
|
||||
interface WithBackgroundColor
|
||||
{
|
||||
/**
|
||||
* @return string|array|Color
|
||||
*/
|
||||
public function backgroundColor();
|
||||
}
|
@@ -10,8 +10,7 @@ trait WithConditionalSheets
|
||||
protected $conditionallySelectedSheets = [];
|
||||
|
||||
/**
|
||||
* @param string|array $sheets
|
||||
*
|
||||
* @param string|array $sheets
|
||||
* @return $this
|
||||
*/
|
||||
public function onlySheets($sheets)
|
||||
|
13
vendor/maatwebsite/excel/src/Concerns/WithDefaultStyles.php
vendored
Normal file
13
vendor/maatwebsite/excel/src/Concerns/WithDefaultStyles.php
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Concerns;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Style\Style;
|
||||
|
||||
interface WithDefaultStyles
|
||||
{
|
||||
/**
|
||||
* @return array|void
|
||||
*/
|
||||
public function defaultStyles(Style $defaultStyle);
|
||||
}
|
7
vendor/maatwebsite/excel/src/Concerns/WithGroupedHeadingRow.php
vendored
Normal file
7
vendor/maatwebsite/excel/src/Concerns/WithGroupedHeadingRow.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Maatwebsite\Excel\Concerns;
|
||||
|
||||
interface WithGroupedHeadingRow extends WithHeadingRow
|
||||
{
|
||||
}
|
@@ -5,8 +5,7 @@ namespace Maatwebsite\Excel\Concerns;
|
||||
interface WithMapping
|
||||
{
|
||||
/**
|
||||
* @param mixed $row
|
||||
*
|
||||
* @param mixed $row
|
||||
* @return array
|
||||
*/
|
||||
public function map($row): array;
|
||||
|
@@ -51,8 +51,7 @@ class ExportMakeCommand extends GeneratorCommand
|
||||
/**
|
||||
* Get the default namespace for the class.
|
||||
*
|
||||
* @param string $rootNamespace
|
||||
*
|
||||
* @param string $rootNamespace
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultNamespace($rootNamespace)
|
||||
@@ -64,8 +63,7 @@ class ExportMakeCommand extends GeneratorCommand
|
||||
* Build the class with the given name.
|
||||
* Remove the base controller import if we are already in base namespace.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
protected function buildClass($name)
|
||||
|
@@ -45,8 +45,7 @@ class ImportMakeCommand extends GeneratorCommand
|
||||
/**
|
||||
* Get the default namespace for the class.
|
||||
*
|
||||
* @param string $rootNamespace
|
||||
*
|
||||
* @param string $rootNamespace
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultNamespace($rootNamespace)
|
||||
@@ -58,8 +57,7 @@ class ImportMakeCommand extends GeneratorCommand
|
||||
* Build the class with the given name.
|
||||
* Remove the base controller import if we are already in base namespace.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
protected function buildClass($name)
|
||||
|
@@ -10,8 +10,7 @@ trait WithModelStub
|
||||
/**
|
||||
* Build the model replacement values.
|
||||
*
|
||||
* @param array $replace
|
||||
*
|
||||
* @param array $replace
|
||||
* @return array
|
||||
*/
|
||||
protected function buildModelReplacements(array $replace): array
|
||||
@@ -27,8 +26,7 @@ trait WithModelStub
|
||||
/**
|
||||
* Get the fully-qualified model class name.
|
||||
*
|
||||
* @param string $model
|
||||
*
|
||||
* @param string $model
|
||||
* @return string
|
||||
*/
|
||||
protected function parseModel($model): string
|
||||
@@ -37,12 +35,20 @@ trait WithModelStub
|
||||
throw new InvalidArgumentException('Model name contains invalid characters.');
|
||||
}
|
||||
|
||||
$model = trim(str_replace('/', '\\', $model), '\\');
|
||||
$model = ltrim($model, '\\/');
|
||||
|
||||
if (!Str::startsWith($model, $rootNamespace = $this->laravel->getNamespace())) {
|
||||
$model = $rootNamespace . $model;
|
||||
$model = str_replace('/', '\\', $model);
|
||||
|
||||
$rootNamespace = $this->rootNamespace();
|
||||
|
||||
if (Str::startsWith($model, $rootNamespace)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
$model = is_dir(app_path('Models'))
|
||||
? $rootNamespace . 'Models\\' . $model
|
||||
: $rootNamespace . $model;
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
@@ -8,9 +8,8 @@ use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder as PhpSpreadsheetDefaultVal
|
||||
class DefaultValueBinder extends PhpSpreadsheetDefaultValueBinder
|
||||
{
|
||||
/**
|
||||
* @param Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
*
|
||||
* @param Cell $cell Cell to bind value to
|
||||
* @param mixed $value Value to bind in cell
|
||||
* @return bool
|
||||
*/
|
||||
public function bindValue(Cell $cell, $value)
|
||||
|
@@ -13,9 +13,8 @@ trait DelegatedMacroable
|
||||
/**
|
||||
* Dynamically handle calls to the class.
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
|
@@ -17,8 +17,8 @@ class AfterImport extends Event
|
||||
private $importable;
|
||||
|
||||
/**
|
||||
* @param Reader $reader
|
||||
* @param object $importable
|
||||
* @param Reader $reader
|
||||
* @param object $importable
|
||||
*/
|
||||
public function __construct(Reader $reader, $importable)
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ class AfterSheet extends Event
|
||||
private $exportable;
|
||||
|
||||
/**
|
||||
* @param Sheet $sheet
|
||||
* @param object $exportable
|
||||
* @param Sheet $sheet
|
||||
* @param object $exportable
|
||||
*/
|
||||
public function __construct(Sheet $sheet, $exportable)
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ class BeforeExport extends Event
|
||||
private $exportable;
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param object $exportable
|
||||
* @param Writer $writer
|
||||
* @param object $exportable
|
||||
*/
|
||||
public function __construct(Writer $writer, $exportable)
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ class BeforeImport extends Event
|
||||
private $importable;
|
||||
|
||||
/**
|
||||
* @param Reader $reader
|
||||
* @param object $importable
|
||||
* @param Reader $reader
|
||||
* @param object $importable
|
||||
*/
|
||||
public function __construct(Reader $reader, $importable)
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ class BeforeSheet extends Event
|
||||
private $exportable;
|
||||
|
||||
/**
|
||||
* @param Sheet $sheet
|
||||
* @param object $exportable
|
||||
* @param Sheet $sheet
|
||||
* @param object $exportable
|
||||
*/
|
||||
public function __construct(Sheet $sheet, $exportable)
|
||||
{
|
||||
|
@@ -17,8 +17,8 @@ class BeforeWriting extends Event
|
||||
private $exportable;
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param object $exportable
|
||||
* @param Writer $writer
|
||||
* @param object $exportable
|
||||
*/
|
||||
public function __construct(Writer $writer, $exportable)
|
||||
{
|
||||
|
@@ -15,8 +15,7 @@ abstract class Event
|
||||
abstract public function getDelegate();
|
||||
|
||||
/**
|
||||
* @param string $concern
|
||||
*
|
||||
* @param string $concern
|
||||
* @return bool
|
||||
*/
|
||||
public function appliesToConcern(string $concern): bool
|
||||
|
16
vendor/maatwebsite/excel/src/Excel.php
vendored
16
vendor/maatwebsite/excel/src/Excel.php
vendored
@@ -58,10 +58,10 @@ class Excel implements Exporter, Importer
|
||||
private $reader;
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param QueuedWriter $queuedWriter
|
||||
* @param Reader $reader
|
||||
* @param Filesystem $filesystem
|
||||
* @param Writer $writer
|
||||
* @param QueuedWriter $queuedWriter
|
||||
* @param Reader $reader
|
||||
* @param Filesystem $filesystem
|
||||
*/
|
||||
public function __construct(
|
||||
Writer $writer,
|
||||
@@ -181,12 +181,12 @@ class Excel implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string|null $fileName
|
||||
* @param string $writerType
|
||||
* @param object $export
|
||||
* @param string|null $fileName
|
||||
* @param string $writerType
|
||||
* @return TemporaryFile
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @return TemporaryFile
|
||||
*/
|
||||
protected function export($export, string $fileName, string $writerType = null): TemporaryFile
|
||||
{
|
||||
|
@@ -66,7 +66,7 @@ class ExcelServiceProvider extends ServiceProvider
|
||||
return new CacheManager($app);
|
||||
});
|
||||
|
||||
$this->app->bind(TransactionManager::class, function ($app) {
|
||||
$this->app->singleton(TransactionManager::class, function ($app) {
|
||||
return new TransactionManager($app);
|
||||
});
|
||||
|
||||
|
@@ -8,9 +8,9 @@ use Throwable;
|
||||
class NoFilePathGivenException extends InvalidArgumentException implements LaravelExcelException
|
||||
{
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(
|
||||
$message = 'A filepath needs to be passed.',
|
||||
|
@@ -8,9 +8,9 @@ use Throwable;
|
||||
class NoFilenameGivenException extends InvalidArgumentException implements LaravelExcelException
|
||||
{
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(
|
||||
$message = 'A filename needs to be passed in order to download the export',
|
||||
|
@@ -8,9 +8,9 @@ use Throwable;
|
||||
class NoTypeDetectedException extends Exception implements LaravelExcelException
|
||||
{
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(
|
||||
$message = 'No ReaderType or WriterType could be detected. Make sure you either pass a valid extension to the filename or pass an explicit type.',
|
||||
|
@@ -14,7 +14,7 @@ class RowSkippedException extends Exception
|
||||
private $failures;
|
||||
|
||||
/**
|
||||
* @param Failure ...$failures
|
||||
* @param Failure ...$failures
|
||||
*/
|
||||
public function __construct(Failure ...$failures)
|
||||
{
|
||||
|
@@ -5,8 +5,7 @@ namespace Maatwebsite\Excel\Exceptions;
|
||||
class SheetNotFoundException extends \Exception implements LaravelExcelException
|
||||
{
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @param string $name
|
||||
* @return SheetNotFoundException
|
||||
*/
|
||||
public static function byName(string $name): SheetNotFoundException
|
||||
@@ -15,9 +14,8 @@ class SheetNotFoundException extends \Exception implements LaravelExcelException
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $index
|
||||
* @param int $sheetCount
|
||||
*
|
||||
* @param int $index
|
||||
* @param int $sheetCount
|
||||
* @return SheetNotFoundException
|
||||
*/
|
||||
public static function byIndex(int $index, int $sheetCount): SheetNotFoundException
|
||||
|
@@ -8,9 +8,9 @@ use Throwable;
|
||||
class UnreadableFileException extends Exception implements LaravelExcelException
|
||||
{
|
||||
/**
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
* @param string $message
|
||||
* @param int $code
|
||||
* @param Throwable|null $previous
|
||||
*/
|
||||
public function __construct(
|
||||
$message = 'File could not be read',
|
||||
|
38
vendor/maatwebsite/excel/src/Exporter.php
vendored
38
vendor/maatwebsite/excel/src/Exporter.php
vendored
@@ -5,45 +5,43 @@ namespace Maatwebsite\Excel;
|
||||
interface Exporter
|
||||
{
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string|null $fileName
|
||||
* @param string $writerType
|
||||
* @param array $headers
|
||||
* @param object $export
|
||||
* @param string|null $fileName
|
||||
* @param string $writerType
|
||||
* @param array $headers
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
*/
|
||||
public function download($export, string $fileName, string $writerType = null, array $headers = []);
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param string $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @param object $export
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param string $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @return bool
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
* @return bool
|
||||
*/
|
||||
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []);
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param string $writerType
|
||||
* @param mixed $diskOptions
|
||||
*
|
||||
* @param object $export
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param string $writerType
|
||||
* @param mixed $diskOptions
|
||||
* @return \Illuminate\Foundation\Bus\PendingDispatch
|
||||
*/
|
||||
public function queue($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = []);
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
*
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
* @return string
|
||||
*/
|
||||
public function raw($export, string $writerType);
|
||||
|
@@ -14,6 +14,7 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
* @method static BinaryFileResponse download(object $export, string $fileName, string $writerType = null, array $headers = [])
|
||||
* @method static bool store(object $export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
|
||||
* @method static PendingDispatch queue(object $export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
|
||||
* @method static string raw(object $export, string $writerType)
|
||||
* @method static BaseExcel import(object $import, string|UploadedFile $filePath, string $disk = null, string $readerType = null)
|
||||
* @method static array toArray(object $import, string|UploadedFile $filePath, string $disk = null, string $readerType = null)
|
||||
* @method static Collection toCollection(object $import, string|UploadedFile $filePath, string $disk = null, string $readerType = null)
|
||||
@@ -24,6 +25,7 @@ use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
* @method static void assertStored(string $filePath, string|callable $disk = null, callable $callback = null)
|
||||
* @method static void assertQueued(string $filePath, string|callable $disk = null, callable $callback = null)
|
||||
* @method static void assertQueuedWithChain(array $chain)
|
||||
* @method static void assertExportedInRaw(string $classname, callable $callback = null)
|
||||
* @method static void assertImported(string $filePath, string|callable $disk = null, callable $callback = null)
|
||||
*/
|
||||
class Excel extends Facade
|
||||
|
@@ -20,12 +20,12 @@ class ReaderFactory
|
||||
use MapsCsvSettings;
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param TemporaryFile $file
|
||||
* @param string $readerType
|
||||
* @param object $import
|
||||
* @param TemporaryFile $file
|
||||
* @param string $readerType
|
||||
* @return IReader
|
||||
*
|
||||
* @throws Exception
|
||||
* @return IReader
|
||||
*/
|
||||
public static function make($import, TemporaryFile $file, string $readerType = null): IReader
|
||||
{
|
||||
@@ -53,6 +53,9 @@ class ReaderFactory
|
||||
$reader->setEscapeCharacter(static::$escapeCharacter);
|
||||
$reader->setContiguous(static::$contiguous);
|
||||
$reader->setInputEncoding(static::$inputEncoding);
|
||||
if (method_exists($reader, 'setTestAutoDetect')) {
|
||||
$reader->setTestAutoDetect(static::$testAutoDetect);
|
||||
}
|
||||
}
|
||||
|
||||
if ($import instanceof WithReadFilter) {
|
||||
@@ -68,10 +71,10 @@ class ReaderFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @return string
|
||||
*
|
||||
* @throws NoTypeDetectedException
|
||||
* @return string
|
||||
*/
|
||||
private static function identify(TemporaryFile $temporaryFile): string
|
||||
{
|
||||
|
@@ -19,12 +19,12 @@ class WriterFactory
|
||||
use MapsCsvSettings;
|
||||
|
||||
/**
|
||||
* @param string $writerType
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param object $export
|
||||
* @return IWriter
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
* @return IWriter
|
||||
*/
|
||||
public static function make(string $writerType, Spreadsheet $spreadsheet, $export): IWriter
|
||||
{
|
||||
@@ -56,6 +56,7 @@ class WriterFactory
|
||||
$writer->setUseBOM(static::$useBom);
|
||||
$writer->setIncludeSeparatorLine(static::$includeSeparatorLine);
|
||||
$writer->setExcelCompatibility(static::$excelCompatibility);
|
||||
$writer->setOutputEncoding(static::$outputEncoding);
|
||||
}
|
||||
|
||||
// Calculation settings
|
||||
@@ -70,7 +71,6 @@ class WriterFactory
|
||||
|
||||
/**
|
||||
* @param $export
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private static function includesCharts($export): bool
|
||||
|
106
vendor/maatwebsite/excel/src/Fakes/ExcelFake.php
vendored
106
vendor/maatwebsite/excel/src/Fakes/ExcelFake.php
vendored
@@ -31,6 +31,11 @@ class ExcelFake implements Exporter, Importer
|
||||
*/
|
||||
protected $queued = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $raws = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
@@ -96,22 +101,22 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
*
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
* @return string
|
||||
*/
|
||||
public function raw($export, string $writerType)
|
||||
{
|
||||
$this->raws[get_class($export)] = $export;
|
||||
|
||||
return 'RAW-CONTENTS';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return Reader|PendingDispatch
|
||||
*/
|
||||
public function import($import, $file, string $disk = null, string $readerType = null)
|
||||
@@ -128,11 +133,10 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($import, $file, string $disk = null, string $readerType = null): array
|
||||
@@ -145,11 +149,10 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return Collection
|
||||
*/
|
||||
public function toCollection($import, $file, string $disk = null, string $readerType = null): Collection
|
||||
@@ -162,11 +165,10 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ShouldQueue $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string $readerType
|
||||
*
|
||||
* @param ShouldQueue $import
|
||||
* @param string|UploadedFile $file
|
||||
* @param string|null $disk
|
||||
* @param string $readerType
|
||||
* @return PendingDispatch
|
||||
*/
|
||||
public function queueImport(ShouldQueue $import, $file, string $disk = null, string $readerType = null)
|
||||
@@ -178,7 +180,7 @@ class ExcelFake implements Exporter, Importer
|
||||
$this->queued[$disk ?? 'default'][$filePath] = $import;
|
||||
$this->imported[$disk ?? 'default'][$filePath] = $import;
|
||||
|
||||
return new PendingDispatch(new class
|
||||
$this->job = new class
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
@@ -186,7 +188,11 @@ class ExcelFake implements Exporter, Importer
|
||||
{
|
||||
//
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Queue::push($this->job);
|
||||
|
||||
return new PendingDispatch($this->job);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,8 +218,8 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
* @param callable|null $callback
|
||||
* @param string $fileName
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function assertDownloaded(string $fileName, $callback = null)
|
||||
{
|
||||
@@ -230,9 +236,9 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string|callable|null $disk
|
||||
* @param callable|null $callback
|
||||
* @param string $filePath
|
||||
* @param string|callable|null $disk
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function assertStored(string $filePath, $disk = null, $callback = null)
|
||||
{
|
||||
@@ -261,9 +267,9 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string|callable|null $disk
|
||||
* @param callable|null $callback
|
||||
* @param string $filePath
|
||||
* @param string|callable|null $disk
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function assertQueued(string $filePath, $disk = null, $callback = null)
|
||||
{
|
||||
@@ -297,9 +303,27 @@ class ExcelFake implements Exporter, Importer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string|callable|null $disk
|
||||
* @param callable|null $callback
|
||||
* @param string $classname
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function assertExportedInRaw(string $classname, $callback = null)
|
||||
{
|
||||
Assert::assertArrayHasKey($classname, $this->raws, sprintf('%s is not exported in raw', $classname));
|
||||
|
||||
$callback = $callback ?: function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
Assert::assertTrue(
|
||||
$callback($this->raws[$classname]),
|
||||
"The [{$classname}] export was not exported in raw with the expected data."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string|callable|null $disk
|
||||
* @param callable|null $callback
|
||||
*/
|
||||
public function assertImported(string $filePath, $disk = null, $callback = null)
|
||||
{
|
||||
@@ -329,12 +353,12 @@ class ExcelFake implements Exporter, Importer
|
||||
|
||||
/**
|
||||
* Asserts that an array has a specified key and returns the key if successful.
|
||||
*
|
||||
* @see matchByRegex for more information about file path matching
|
||||
*
|
||||
* @param string $key
|
||||
* @param array $array
|
||||
* @param string $message
|
||||
*
|
||||
* @param string $key
|
||||
* @param array $array
|
||||
* @param string $message
|
||||
* @return string
|
||||
*
|
||||
* @throws ExpectationFailedException
|
||||
@@ -349,7 +373,7 @@ class ExcelFake implements Exporter, Importer
|
||||
Assert::assertGreaterThan(0, count($results), $message);
|
||||
Assert::assertEquals(1, count($results), "More than one result matches the file name expression '$key'.");
|
||||
|
||||
return $results[0];
|
||||
return array_values($results)[0];
|
||||
}
|
||||
Assert::assertArrayHasKey($key, $disk, $message);
|
||||
|
||||
|
23
vendor/maatwebsite/excel/src/Files/Disk.php
vendored
23
vendor/maatwebsite/excel/src/Files/Disk.php
vendored
@@ -28,9 +28,9 @@ class Disk
|
||||
protected $diskOptions;
|
||||
|
||||
/**
|
||||
* @param IlluminateFilesystem $disk
|
||||
* @param string|null $name
|
||||
* @param array $diskOptions
|
||||
* @param IlluminateFilesystem $disk
|
||||
* @param string|null $name
|
||||
* @param array $diskOptions
|
||||
*/
|
||||
public function __construct(IlluminateFilesystem $disk, string $name = null, array $diskOptions = [])
|
||||
{
|
||||
@@ -40,9 +40,8 @@ class Disk
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $arguments
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($name, $arguments)
|
||||
@@ -51,9 +50,8 @@ class Disk
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $destination
|
||||
* @param string|resource $contents
|
||||
*
|
||||
* @param string $destination
|
||||
* @param string|resource $contents
|
||||
* @return bool
|
||||
*/
|
||||
public function put(string $destination, $contents): bool
|
||||
@@ -62,9 +60,8 @@ class Disk
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TemporaryFile $source
|
||||
* @param string $destination
|
||||
*
|
||||
* @param TemporaryFile $source
|
||||
* @param string $destination
|
||||
* @return bool
|
||||
*/
|
||||
public function copy(TemporaryFile $source, string $destination): bool
|
||||
@@ -90,7 +87,7 @@ class Disk
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param string $filename
|
||||
*/
|
||||
public function touch(string $filename)
|
||||
{
|
||||
|
@@ -12,7 +12,7 @@ class Filesystem
|
||||
private $filesystem;
|
||||
|
||||
/**
|
||||
* @param Factory $filesystem
|
||||
* @param Factory $filesystem
|
||||
*/
|
||||
public function __construct(Factory $filesystem)
|
||||
{
|
||||
@@ -20,9 +20,8 @@ class Filesystem
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $disk
|
||||
* @param array $diskOptions
|
||||
*
|
||||
* @param string|null $disk
|
||||
* @param array $diskOptions
|
||||
* @return Disk
|
||||
*/
|
||||
public function disk(string $disk = null, array $diskOptions = []): Disk
|
||||
|
@@ -10,7 +10,7 @@ class LocalTemporaryFile extends TemporaryFile
|
||||
private $filePath;
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string $filePath
|
||||
*/
|
||||
public function __construct(string $filePath)
|
||||
{
|
||||
|
@@ -25,9 +25,9 @@ class RemoteTemporaryFile extends TemporaryFile
|
||||
private $localTemporaryFile;
|
||||
|
||||
/**
|
||||
* @param string $disk
|
||||
* @param string $filename
|
||||
* @param LocalTemporaryFile $localTemporaryFile
|
||||
* @param string $disk
|
||||
* @param string $filename
|
||||
* @param LocalTemporaryFile $localTemporaryFile
|
||||
*/
|
||||
public function __construct(string $disk, string $filename, LocalTemporaryFile $localTemporaryFile)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ class RemoteTemporaryFile extends TemporaryFile
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|resource $contents
|
||||
* @param string|resource $contents
|
||||
*/
|
||||
public function put($contents)
|
||||
{
|
||||
|
@@ -45,9 +45,8 @@ abstract class TemporaryFile
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
*
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @return TemporaryFile
|
||||
*/
|
||||
public function copyFrom($filePath, string $disk = null): TemporaryFile
|
||||
|
@@ -17,8 +17,8 @@ class TemporaryFileFactory
|
||||
private $temporaryDisk;
|
||||
|
||||
/**
|
||||
* @param string|null $temporaryPath
|
||||
* @param string|null $temporaryDisk
|
||||
* @param string|null $temporaryPath
|
||||
* @param string|null $temporaryDisk
|
||||
*/
|
||||
public function __construct(string $temporaryPath = null, string $temporaryDisk = null)
|
||||
{
|
||||
@@ -27,8 +27,7 @@ class TemporaryFileFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $fileExtension
|
||||
*
|
||||
* @param string|null $fileExtension
|
||||
* @return TemporaryFile
|
||||
*/
|
||||
public function make(string $fileExtension = null): TemporaryFile
|
||||
@@ -41,10 +40,8 @@ class TemporaryFileFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $fileName
|
||||
*
|
||||
* @param string|null $fileExtension
|
||||
*
|
||||
* @param string|null $fileName
|
||||
* @param string|null $fileExtension
|
||||
* @return LocalTemporaryFile
|
||||
*/
|
||||
public function makeLocal(string $fileName = null, string $fileExtension = null): LocalTemporaryFile
|
||||
@@ -59,8 +56,7 @@ class TemporaryFileFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $fileExtension
|
||||
*
|
||||
* @param string|null $fileExtension
|
||||
* @return RemoteTemporaryFile
|
||||
*/
|
||||
private function makeRemote(string $fileExtension = null): RemoteTemporaryFile
|
||||
@@ -75,8 +71,7 @@ class TemporaryFileFactory
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $fileExtension
|
||||
*
|
||||
* @param string|null $fileExtension
|
||||
* @return string
|
||||
*/
|
||||
private function generateFilename(string $fileExtension = null): string
|
||||
|
@@ -27,10 +27,10 @@ class ChunkReadFilter implements IReadFilter
|
||||
private $worksheetName;
|
||||
|
||||
/**
|
||||
* @param int $headingRow
|
||||
* @param int $startRow
|
||||
* @param int $chunkSize
|
||||
* @param string $worksheetName
|
||||
* @param int $headingRow
|
||||
* @param int $startRow
|
||||
* @param int $chunkSize
|
||||
* @param string $worksheetName
|
||||
*/
|
||||
public function __construct(int $headingRow, int $startRow, int $chunkSize, string $worksheetName)
|
||||
{
|
||||
@@ -41,10 +41,9 @@ class ChunkReadFilter implements IReadFilter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param int $row
|
||||
* @param string $worksheetName
|
||||
*
|
||||
* @param string $column
|
||||
* @param int $row
|
||||
* @param string $worksheetName
|
||||
* @return bool
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
|
@@ -17,8 +17,8 @@ class LimitFilter implements IReadFilter
|
||||
private $endRow;
|
||||
|
||||
/**
|
||||
* @param int $startRow
|
||||
* @param int $limit
|
||||
* @param int $startRow
|
||||
* @param int $limit
|
||||
*/
|
||||
public function __construct(int $startRow, int $limit)
|
||||
{
|
||||
@@ -27,10 +27,9 @@ class LimitFilter implements IReadFilter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param int $row
|
||||
* @param string $worksheetName
|
||||
*
|
||||
* @param string $column
|
||||
* @param int $row
|
||||
* @param string $worksheetName
|
||||
* @return bool
|
||||
*/
|
||||
public function readCell($column, $row, $worksheetName = '')
|
||||
|
11
vendor/maatwebsite/excel/src/HasEventBus.php
vendored
11
vendor/maatwebsite/excel/src/HasEventBus.php
vendored
@@ -17,7 +17,7 @@ trait HasEventBus
|
||||
/**
|
||||
* Register local event listeners.
|
||||
*
|
||||
* @param array $listeners
|
||||
* @param array $listeners
|
||||
*/
|
||||
public function registerListeners(array $listeners)
|
||||
{
|
||||
@@ -34,8 +34,8 @@ trait HasEventBus
|
||||
/**
|
||||
* Register a global event listener.
|
||||
*
|
||||
* @param string $event
|
||||
* @param callable $listener
|
||||
* @param string $event
|
||||
* @param callable $listener
|
||||
*/
|
||||
public static function listen(string $event, callable $listener)
|
||||
{
|
||||
@@ -43,7 +43,7 @@ trait HasEventBus
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $event
|
||||
* @param object $event
|
||||
*/
|
||||
public function raise($event)
|
||||
{
|
||||
@@ -53,8 +53,7 @@ trait HasEventBus
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $event
|
||||
*
|
||||
* @param object $event
|
||||
* @return callable[]
|
||||
*/
|
||||
public function listeners($event): array
|
||||
|
@@ -18,7 +18,7 @@ class HeadingRowImport implements WithStartRow, WithLimit, WithMapping
|
||||
private $headingRow;
|
||||
|
||||
/**
|
||||
* @param int $headingRow
|
||||
* @param int $headingRow
|
||||
*/
|
||||
public function __construct(int $headingRow = 1)
|
||||
{
|
||||
@@ -42,8 +42,7 @@ class HeadingRowImport implements WithStartRow, WithLimit, WithMapping
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $row
|
||||
*
|
||||
* @param mixed $row
|
||||
* @return array
|
||||
*/
|
||||
public function map($row): array
|
||||
|
@@ -5,8 +5,7 @@ namespace Maatwebsite\Excel\Helpers;
|
||||
class ArrayHelper
|
||||
{
|
||||
/**
|
||||
* @param array $array
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
public static function ensureMultipleRows(array $array): array
|
||||
@@ -22,8 +21,7 @@ class ArrayHelper
|
||||
* Only have multiple rows, if each
|
||||
* element in the array is an array itself.
|
||||
*
|
||||
* @param array $array
|
||||
*
|
||||
* @param array $array
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasMultipleRows(array $array): bool
|
||||
|
@@ -5,8 +5,7 @@ namespace Maatwebsite\Excel\Helpers;
|
||||
class CellHelper
|
||||
{
|
||||
/**
|
||||
* @param string $coordinate
|
||||
*
|
||||
* @param string $coordinate
|
||||
* @return string
|
||||
*/
|
||||
public static function getColumnFromCoordinate(string $coordinate): string
|
||||
|
@@ -8,11 +8,11 @@ use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
class FileTypeDetector
|
||||
{
|
||||
/**
|
||||
* @param $filePath
|
||||
* @param string|null $type
|
||||
* @param $filePath
|
||||
* @param string|null $type
|
||||
* @return string|null
|
||||
*
|
||||
* @throws NoTypeDetectedException
|
||||
* @return string|null
|
||||
*/
|
||||
public static function detect($filePath, string $type = null)
|
||||
{
|
||||
@@ -35,11 +35,11 @@ class FileTypeDetector
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filePath
|
||||
* @param string|null $type
|
||||
* @param string $filePath
|
||||
* @param string|null $type
|
||||
* @return string
|
||||
*
|
||||
* @throws NoTypeDetectedException
|
||||
* @return string
|
||||
*/
|
||||
public static function detectStrict(string $filePath, string $type = null): string
|
||||
{
|
||||
|
36
vendor/maatwebsite/excel/src/Importer.php
vendored
36
vendor/maatwebsite/excel/src/Importer.php
vendored
@@ -8,41 +8,37 @@ use Illuminate\Support\Collection;
|
||||
interface Importer
|
||||
{
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return Reader|\Illuminate\Foundation\Bus\PendingDispatch
|
||||
*/
|
||||
public function import($import, $filePath, string $disk = null, string $readerType = null);
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($import, $filePath, string $disk = null, string $readerType = null): array;
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string|null $readerType
|
||||
* @return Collection
|
||||
*/
|
||||
public function toCollection($import, $filePath, string $disk = null, string $readerType = null): Collection;
|
||||
|
||||
/**
|
||||
* @param ShouldQueue $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string $readerType
|
||||
*
|
||||
* @param ShouldQueue $import
|
||||
* @param string|\Symfony\Component\HttpFoundation\File\UploadedFile $filePath
|
||||
* @param string|null $disk
|
||||
* @param string $readerType
|
||||
* @return \Illuminate\Foundation\Bus\PendingDispatch
|
||||
*/
|
||||
public function queueImport(ShouldQueue $import, $filePath, string $disk = null, string $readerType = null);
|
||||
|
@@ -7,11 +7,9 @@ use Maatwebsite\Excel\Concerns\WithLimit;
|
||||
class EndRowFinder
|
||||
{
|
||||
/**
|
||||
* @param object|WithLimit $import
|
||||
* @param int $startRow
|
||||
*
|
||||
* @param int|null $highestRow
|
||||
*
|
||||
* @param object|WithLimit $import
|
||||
* @param int $startRow
|
||||
* @param int|null $highestRow
|
||||
* @return int|null
|
||||
*/
|
||||
public static function find($import, int $startRow = null, int $highestRow = null)
|
||||
|
@@ -3,6 +3,7 @@
|
||||
namespace Maatwebsite\Excel\Imports;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\WithColumnLimit;
|
||||
use Maatwebsite\Excel\Concerns\WithGroupedHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadingRow;
|
||||
use Maatwebsite\Excel\Concerns\WithStartRow;
|
||||
use Maatwebsite\Excel\Row;
|
||||
@@ -16,8 +17,7 @@ class HeadingRowExtractor
|
||||
const DEFAULT_HEADING_ROW = 1;
|
||||
|
||||
/**
|
||||
* @param WithHeadingRow|mixed $importable
|
||||
*
|
||||
* @param WithHeadingRow|mixed $importable
|
||||
* @return int
|
||||
*/
|
||||
public static function headingRow($importable): int
|
||||
@@ -28,8 +28,7 @@ class HeadingRowExtractor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WithHeadingRow|mixed $importable
|
||||
*
|
||||
* @param WithHeadingRow|mixed $importable
|
||||
* @return int
|
||||
*/
|
||||
public static function determineStartRow($importable): int
|
||||
@@ -45,9 +44,8 @@ class HeadingRowExtractor
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Worksheet $worksheet
|
||||
* @param WithHeadingRow|mixed $importable
|
||||
*
|
||||
* @param Worksheet $worksheet
|
||||
* @param WithHeadingRow|mixed $importable
|
||||
* @return array
|
||||
*/
|
||||
public static function extract(Worksheet $worksheet, $importable): array
|
||||
@@ -63,4 +61,26 @@ class HeadingRowExtractor
|
||||
|
||||
return HeadingRowFormatter::format((new Row($headingRow))->toArray(null, false, false, $endColumn));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $headingRow
|
||||
* @param WithGroupedHeadingRow|mixed $importable
|
||||
* @return array
|
||||
*/
|
||||
public static function extractGrouping($headingRow, $importable)
|
||||
{
|
||||
$headerIsGrouped = array_fill(0, count($headingRow), false);
|
||||
|
||||
if (!$importable instanceof WithGroupedHeadingRow) {
|
||||
return $headerIsGrouped;
|
||||
}
|
||||
|
||||
array_walk($headerIsGrouped, function (&$value, $key) use ($headingRow) {
|
||||
if (array_count_values($headingRow)[$headingRow[$key]] > 1) {
|
||||
$value = true;
|
||||
}
|
||||
});
|
||||
|
||||
return $headerIsGrouped;
|
||||
}
|
||||
}
|
||||
|
@@ -37,8 +37,7 @@ class HeadingRowFormatter
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $headings
|
||||
*
|
||||
* @param array $headings
|
||||
* @return array
|
||||
*/
|
||||
public static function format(array $headings): array
|
||||
@@ -49,7 +48,7 @@ class HeadingRowFormatter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
*/
|
||||
public static function default(string $name = null)
|
||||
{
|
||||
@@ -61,8 +60,8 @@ class HeadingRowFormatter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param callable $formatter
|
||||
* @param string $name
|
||||
* @param callable $formatter
|
||||
*/
|
||||
public static function extend(string $name, callable $formatter)
|
||||
{
|
||||
@@ -78,8 +77,7 @@ class HeadingRowFormatter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @param mixed $value
|
||||
* @return mixed
|
||||
*/
|
||||
protected static function callFormatter($value, $key=null)
|
||||
@@ -93,6 +91,10 @@ class HeadingRowFormatter
|
||||
return $formatter($value, $key);
|
||||
}
|
||||
|
||||
if (empty($value)) {
|
||||
return $key;
|
||||
}
|
||||
|
||||
if (static::$formatter === self::FORMATTER_SLUG) {
|
||||
return Str::slug($value, '_');
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ class ModelImporter
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* @param ModelManager $manager
|
||||
* @param ModelManager $manager
|
||||
*/
|
||||
public function __construct(ModelManager $manager)
|
||||
{
|
||||
@@ -30,10 +30,10 @@ class ModelImporter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Worksheet $worksheet
|
||||
* @param ToModel $import
|
||||
* @param int|null $startRow
|
||||
* @param string|null $endColumn
|
||||
* @param Worksheet $worksheet
|
||||
* @param ToModel $import
|
||||
* @param int|null $startRow
|
||||
* @param string|null $endColumn
|
||||
*
|
||||
* @throws \Maatwebsite\Excel\Validators\ValidationException
|
||||
*/
|
||||
@@ -44,6 +44,7 @@ class ModelImporter
|
||||
}
|
||||
|
||||
$headingRow = HeadingRowExtractor::extract($worksheet, $import);
|
||||
$headerIsGrouped = HeadingRowExtractor::extractGrouping($headingRow, $import);
|
||||
$batchSize = $import instanceof WithBatchInserts ? $import->batchSize() : 1;
|
||||
$endRow = EndRowFinder::find($import, $startRow, $worksheet->getHighestRow());
|
||||
$progessBar = $import instanceof WithProgressBar;
|
||||
@@ -59,8 +60,8 @@ class ModelImporter
|
||||
foreach ($worksheet->getRowIterator($startRow, $endRow) as $spreadSheetRow) {
|
||||
$i++;
|
||||
|
||||
$row = new Row($spreadSheetRow, $headingRow);
|
||||
if (!$import instanceof SkipsEmptyRows || ($import instanceof SkipsEmptyRows && !$row->isEmpty())) {
|
||||
$row = new Row($spreadSheetRow, $headingRow, $headerIsGrouped);
|
||||
if (!$import instanceof SkipsEmptyRows || ($import instanceof SkipsEmptyRows && !$row->isEmpty($withCalcFormulas))) {
|
||||
$rowArray = $row->toArray(null, $withCalcFormulas, $formatData, $endColumn);
|
||||
|
||||
if ($withValidation) {
|
||||
|
@@ -31,7 +31,7 @@ class ModelManager
|
||||
private $remembersRowNumber = false;
|
||||
|
||||
/**
|
||||
* @param RowValidator $validator
|
||||
* @param RowValidator $validator
|
||||
*/
|
||||
public function __construct(RowValidator $validator)
|
||||
{
|
||||
@@ -39,8 +39,8 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $row
|
||||
* @param array $attributes
|
||||
* @param int $row
|
||||
* @param array $attributes
|
||||
*/
|
||||
public function add(int $row, array $attributes)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $remembersRowNumber
|
||||
* @param bool $remembersRowNumber
|
||||
*/
|
||||
public function setRemembersRowNumber(bool $remembersRowNumber)
|
||||
{
|
||||
@@ -56,8 +56,8 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ToModel $import
|
||||
* @param bool $massInsert
|
||||
* @param ToModel $import
|
||||
* @param bool $massInsert
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@@ -77,10 +77,9 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ToModel $import
|
||||
* @param array $attributes
|
||||
*
|
||||
* @param int|null $rowNumber
|
||||
* @param ToModel $import
|
||||
* @param array $attributes
|
||||
* @param int|null $rowNumber
|
||||
* @return Model[]|Collection
|
||||
*/
|
||||
public function toModels(ToModel $import, array $attributes, $rowNumber = null): Collection
|
||||
@@ -99,7 +98,7 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ToModel $import
|
||||
* @param ToModel $import
|
||||
*/
|
||||
private function massFlush(ToModel $import)
|
||||
{
|
||||
@@ -134,7 +133,7 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ToModel $import
|
||||
* @param ToModel $import
|
||||
*/
|
||||
private function singleFlush(ToModel $import)
|
||||
{
|
||||
@@ -164,8 +163,7 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Model $model
|
||||
*
|
||||
* @param Model $model
|
||||
* @return Model
|
||||
*/
|
||||
private function prepare(Model $model): Model
|
||||
@@ -192,7 +190,7 @@ class ModelManager
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WithValidation $import
|
||||
* @param WithValidation $import
|
||||
*
|
||||
* @throws ValidationException
|
||||
*/
|
||||
|
@@ -25,8 +25,8 @@ class AfterImportJob implements ShouldQueue
|
||||
private $reader;
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param Reader $reader
|
||||
* @param object $import
|
||||
* @param Reader $reader
|
||||
*/
|
||||
public function __construct($import, Reader $reader)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ class AfterImportJob implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Throwable $e
|
||||
* @param Throwable $e
|
||||
*/
|
||||
public function failed(Throwable $e)
|
||||
{
|
||||
|
@@ -5,13 +5,14 @@ namespace Maatwebsite\Excel\Jobs;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Maatwebsite\Excel\Files\TemporaryFile;
|
||||
use Maatwebsite\Excel\Jobs\Middleware\LocalizeJob;
|
||||
use Maatwebsite\Excel\Writer;
|
||||
|
||||
class AppendDataToSheet implements ShouldQueue
|
||||
{
|
||||
use Queueable, Dispatchable, ProxyFailures;
|
||||
use Queueable, Dispatchable, ProxyFailures, InteractsWithQueue;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
@@ -39,11 +40,11 @@ class AppendDataToSheet implements ShouldQueue
|
||||
public $sheetExport;
|
||||
|
||||
/**
|
||||
* @param object $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param array $data
|
||||
* @param object $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct($sheetExport, TemporaryFile $temporaryFile, string $writerType, int $sheetIndex, array $data)
|
||||
{
|
||||
@@ -65,7 +66,7 @@ class AppendDataToSheet implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param Writer $writer
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
|
@@ -5,6 +5,7 @@ namespace Maatwebsite\Excel\Jobs;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Maatwebsite\Excel\Concerns\FromQuery;
|
||||
use Maatwebsite\Excel\Files\TemporaryFile;
|
||||
use Maatwebsite\Excel\Jobs\Middleware\LocalizeJob;
|
||||
@@ -12,7 +13,7 @@ use Maatwebsite\Excel\Writer;
|
||||
|
||||
class AppendQueryToSheet implements ShouldQueue
|
||||
{
|
||||
use Queueable, Dispatchable, ProxyFailures;
|
||||
use Queueable, Dispatchable, ProxyFailures, InteractsWithQueue;
|
||||
|
||||
/**
|
||||
* @var TemporaryFile
|
||||
@@ -45,12 +46,12 @@ class AppendQueryToSheet implements ShouldQueue
|
||||
public $chunkSize;
|
||||
|
||||
/**
|
||||
* @param FromQuery $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param int $page
|
||||
* @param int $chunkSize
|
||||
* @param FromQuery $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param int $page
|
||||
* @param int $chunkSize
|
||||
*/
|
||||
public function __construct(
|
||||
FromQuery $sheetExport,
|
||||
@@ -79,7 +80,7 @@ class AppendQueryToSheet implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param Writer $writer
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
|
@@ -5,6 +5,7 @@ namespace Maatwebsite\Excel\Jobs;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Maatwebsite\Excel\Files\TemporaryFile;
|
||||
use Maatwebsite\Excel\Jobs\Middleware\LocalizeJob;
|
||||
@@ -12,7 +13,7 @@ use Maatwebsite\Excel\Writer;
|
||||
|
||||
class AppendViewToSheet implements ShouldQueue
|
||||
{
|
||||
use Queueable, Dispatchable;
|
||||
use Queueable, Dispatchable, InteractsWithQueue;
|
||||
|
||||
/**
|
||||
* @var TemporaryFile
|
||||
@@ -35,11 +36,11 @@ class AppendViewToSheet implements ShouldQueue
|
||||
public $sheetExport;
|
||||
|
||||
/**
|
||||
* @param FromView $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param array $data
|
||||
* @param FromView $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct(FromView $sheetExport, TemporaryFile $temporaryFile, string $writerType, int $sheetIndex)
|
||||
{
|
||||
@@ -60,7 +61,7 @@ class AppendViewToSheet implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param Writer $writer
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
|
10
vendor/maatwebsite/excel/src/Jobs/CloseSheet.php
vendored
10
vendor/maatwebsite/excel/src/Jobs/CloseSheet.php
vendored
@@ -33,10 +33,10 @@ class CloseSheet implements ShouldQueue
|
||||
private $sheetIndex;
|
||||
|
||||
/**
|
||||
* @param object $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @param object $sheetExport
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
*/
|
||||
public function __construct($sheetExport, TemporaryFile $temporaryFile, string $writerType, int $sheetIndex)
|
||||
{
|
||||
@@ -47,7 +47,7 @@ class CloseSheet implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param Writer $writer
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
|
@@ -12,13 +12,12 @@ trait ExtendedQueueable
|
||||
|
||||
/**
|
||||
* @param $chain
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function chain($chain)
|
||||
{
|
||||
collect($chain)->each(function ($job) {
|
||||
$serialized = method_exists($this, 'serializeJob') ? $this->serializeJob($job) : serialize($job);
|
||||
$serialized = method_exists($this, 'serializeJob') ? $this->serializeJob($job) : serialize($job);
|
||||
$this->chained[] = $serialized;
|
||||
});
|
||||
|
||||
|
@@ -18,7 +18,7 @@ class LocalizeJob
|
||||
/**
|
||||
* LocalizeJob constructor.
|
||||
*
|
||||
* @param object $localizable
|
||||
* @param object $localizable
|
||||
*/
|
||||
public function __construct($localizable)
|
||||
{
|
||||
@@ -28,8 +28,8 @@ class LocalizeJob
|
||||
/**
|
||||
* Handles the job.
|
||||
*
|
||||
* @param mixed $job
|
||||
* @param Closure $next
|
||||
* @param mixed $job
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($job, Closure $next)
|
||||
|
@@ -7,7 +7,7 @@ use Throwable;
|
||||
trait ProxyFailures
|
||||
{
|
||||
/**
|
||||
* @param Throwable $e
|
||||
* @param Throwable $e
|
||||
*/
|
||||
public function failed(Throwable $e)
|
||||
{
|
||||
|
@@ -30,9 +30,9 @@ class QueueExport implements ShouldQueue
|
||||
private $temporaryFile;
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param object $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
*/
|
||||
public function __construct($export, TemporaryFile $temporaryFile, string $writerType)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class QueueExport implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param Writer $writer
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
@@ -78,7 +78,7 @@ class QueueExport implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Throwable $e
|
||||
* @param Throwable $e
|
||||
*/
|
||||
public function failed(Throwable $e)
|
||||
{
|
||||
|
@@ -20,7 +20,7 @@ class QueueImport implements ShouldQueue
|
||||
public $timeout;
|
||||
|
||||
/**
|
||||
* @param ShouldQueue $import
|
||||
* @param ShouldQueue $import
|
||||
*/
|
||||
public function __construct(ShouldQueue $import = null)
|
||||
{
|
||||
|
@@ -31,10 +31,10 @@ class StoreQueuedExport implements ShouldQueue
|
||||
private $diskOptions;
|
||||
|
||||
/**
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param array|string $diskOptions
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $filePath
|
||||
* @param string|null $disk
|
||||
* @param array|string $diskOptions
|
||||
*/
|
||||
public function __construct(TemporaryFile $temporaryFile, string $filePath, string $disk = null, $diskOptions = [])
|
||||
{
|
||||
@@ -45,7 +45,7 @@ class StoreQueuedExport implements ShouldQueue
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Filesystem $filesystem
|
||||
* @param Filesystem $filesystem
|
||||
*/
|
||||
public function handle(Filesystem $filesystem)
|
||||
{
|
||||
|
@@ -14,8 +14,8 @@ use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
class MappedReader
|
||||
{
|
||||
/**
|
||||
* @param WithMappedCells $import
|
||||
* @param Worksheet $worksheet
|
||||
* @param WithMappedCells $import
|
||||
* @param Worksheet $worksheet
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
|
@@ -16,7 +16,7 @@ class DownloadCollection
|
||||
*/
|
||||
public function downloadExcel()
|
||||
{
|
||||
return function (string $fileName, string $writerType = null, $withHeadings = false) {
|
||||
return function (string $fileName, string $writerType = null, $withHeadings = false, array $responseHeaders = []) {
|
||||
$export = new class($this, $withHeadings) implements FromCollection, WithHeadings
|
||||
{
|
||||
use Exportable;
|
||||
@@ -32,8 +32,8 @@ class DownloadCollection
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param bool $withHeading
|
||||
* @param Collection $collection
|
||||
* @param bool $withHeading
|
||||
*/
|
||||
public function __construct(Collection $collection, bool $withHeading = false)
|
||||
{
|
||||
@@ -68,7 +68,7 @@ class DownloadCollection
|
||||
}
|
||||
};
|
||||
|
||||
return $export->download($fileName, $writerType);
|
||||
return $export->download($fileName, $writerType, $responseHeaders);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -30,8 +30,8 @@ class StoreCollection
|
||||
private $collection;
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
* @param bool $withHeadings
|
||||
* @param Collection $collection
|
||||
* @param bool $withHeadings
|
||||
*/
|
||||
public function __construct(Collection $collection, bool $withHeadings = false)
|
||||
{
|
||||
|
52
vendor/maatwebsite/excel/src/QueuedWriter.php
vendored
52
vendor/maatwebsite/excel/src/QueuedWriter.php
vendored
@@ -38,8 +38,8 @@ class QueuedWriter
|
||||
protected $temporaryFileFactory;
|
||||
|
||||
/**
|
||||
* @param Writer $writer
|
||||
* @param TemporaryFileFactory $temporaryFileFactory
|
||||
* @param Writer $writer
|
||||
* @param TemporaryFileFactory $temporaryFileFactory
|
||||
*/
|
||||
public function __construct(Writer $writer, TemporaryFileFactory $temporaryFileFactory)
|
||||
{
|
||||
@@ -49,12 +49,11 @@ class QueuedWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string $filePath
|
||||
* @param string $disk
|
||||
* @param string|null $writerType
|
||||
* @param array|string $diskOptions
|
||||
*
|
||||
* @param object $export
|
||||
* @param string $filePath
|
||||
* @param string $disk
|
||||
* @param string|null $writerType
|
||||
* @param array|string $diskOptions
|
||||
* @return \Illuminate\Foundation\Bus\PendingDispatch
|
||||
*/
|
||||
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
|
||||
@@ -77,10 +76,9 @@ class QueuedWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
*
|
||||
* @param object $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @return Collection
|
||||
*/
|
||||
private function buildExportJobs($export, TemporaryFile $temporaryFile, string $writerType): Collection
|
||||
@@ -107,11 +105,10 @@ class QueuedWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromCollection $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
*
|
||||
* @param FromCollection $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @return Collection
|
||||
*/
|
||||
private function exportCollection(
|
||||
@@ -139,11 +136,10 @@ class QueuedWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromQuery $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
*
|
||||
* @param FromQuery $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @return Collection
|
||||
*/
|
||||
private function exportQuery(
|
||||
@@ -174,11 +170,10 @@ class QueuedWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromView $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
*
|
||||
* @param FromView $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @param int $sheetIndex
|
||||
* @return Collection
|
||||
*/
|
||||
private function exportView(
|
||||
@@ -199,8 +194,7 @@ class QueuedWriter
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object|WithCustomChunkSize $export
|
||||
*
|
||||
* @param object|WithCustomChunkSize $export
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkSize($export): int
|
||||
|
64
vendor/maatwebsite/excel/src/Reader.php
vendored
64
vendor/maatwebsite/excel/src/Reader.php
vendored
@@ -29,6 +29,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
||||
use Throwable;
|
||||
|
||||
/** @mixin Spreadsheet */
|
||||
class Reader
|
||||
{
|
||||
use DelegatedMacroable, HasEventBus;
|
||||
@@ -64,8 +65,8 @@ class Reader
|
||||
protected $reader;
|
||||
|
||||
/**
|
||||
* @param TemporaryFileFactory $temporaryFileFactory
|
||||
* @param TransactionHandler $transaction
|
||||
* @param TemporaryFileFactory $temporaryFileFactory
|
||||
* @param TransactionHandler $transaction
|
||||
*/
|
||||
public function __construct(TemporaryFileFactory $temporaryFileFactory, TransactionHandler $transaction)
|
||||
{
|
||||
@@ -86,12 +87,12 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string|null $readerType
|
||||
* @param string|null $disk
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string|null $readerType
|
||||
* @param string|null $disk
|
||||
* @return \Illuminate\Foundation\Bus\PendingDispatch|$this
|
||||
*
|
||||
* @throws NoTypeDetectedException
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
* @throws Exception
|
||||
@@ -131,6 +132,7 @@ class Reader
|
||||
$this->afterImport($import);
|
||||
} catch (Throwable $e) {
|
||||
$this->raise(new ImportFailed($e));
|
||||
$this->garbageCollect();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -138,18 +140,18 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string $readerType
|
||||
* @param string|null $disk
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string $readerType
|
||||
* @param string|null $disk
|
||||
* @return array
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws NoTypeDetectedException
|
||||
* @throws Exceptions\SheetNotFoundException
|
||||
*/
|
||||
public function toArray($import, $filePath, string $readerType, string $disk = null): array
|
||||
public function toArray($import, $filePath, string $readerType = null, string $disk = null): array
|
||||
{
|
||||
$this->reader = $this->getReader($import, $filePath, $readerType, $disk);
|
||||
|
||||
@@ -182,18 +184,18 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string $readerType
|
||||
* @param string|null $disk
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string $readerType
|
||||
* @param string|null $disk
|
||||
* @return Collection
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws NoTypeDetectedException
|
||||
* @throws Exceptions\SheetNotFoundException
|
||||
*/
|
||||
public function toCollection($import, $filePath, string $readerType, string $disk = null): Collection
|
||||
public function toCollection($import, $filePath, string $readerType = null, string $disk = null): Collection
|
||||
{
|
||||
$this->reader = $this->getReader($import, $filePath, $readerType, $disk);
|
||||
$this->loadSpreadsheet($import);
|
||||
@@ -245,7 +247,7 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param object $import
|
||||
*/
|
||||
public function loadSpreadsheet($import)
|
||||
{
|
||||
@@ -270,7 +272,7 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param object $import
|
||||
*/
|
||||
public function beforeImport($import)
|
||||
{
|
||||
@@ -278,7 +280,7 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param object $import
|
||||
*/
|
||||
public function afterImport($import)
|
||||
{
|
||||
@@ -296,8 +298,7 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
*
|
||||
* @param object $import
|
||||
* @return array
|
||||
*/
|
||||
public function getWorksheets($import): array
|
||||
@@ -357,8 +358,8 @@ class Reader
|
||||
* @param $import
|
||||
* @param $sheetImport
|
||||
* @param $index
|
||||
*
|
||||
* @return Sheet|null
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws SheetNotFoundException
|
||||
*/
|
||||
@@ -384,8 +385,7 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
*
|
||||
* @param object $import
|
||||
* @return array
|
||||
*/
|
||||
private function buildSheetImports($import): array
|
||||
@@ -408,12 +408,12 @@ class Reader
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string|null $readerType
|
||||
* @param string $disk
|
||||
*
|
||||
* @param object $import
|
||||
* @param string|UploadedFile $filePath
|
||||
* @param string|null $readerType
|
||||
* @param string $disk
|
||||
* @return IReader
|
||||
*
|
||||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
|
||||
* @throws NoTypeDetectedException
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
|
@@ -21,9 +21,9 @@ trait RegistersCustomConcerns
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $concern
|
||||
* @param callable $handler
|
||||
* @param string $event
|
||||
* @param string $concern
|
||||
* @param callable $handler
|
||||
* @param string $event
|
||||
*/
|
||||
public static function extend(string $concern, callable $handler, string $event = BeforeWriting::class)
|
||||
{
|
||||
|
61
vendor/maatwebsite/excel/src/Row.php
vendored
61
vendor/maatwebsite/excel/src/Row.php
vendored
@@ -7,6 +7,7 @@ use Closure;
|
||||
use Illuminate\Support\Collection;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Row as SpreadsheetRow;
|
||||
|
||||
/** @mixin SpreadsheetRow */
|
||||
class Row implements ArrayAccess
|
||||
{
|
||||
use DelegatedMacroable;
|
||||
@@ -32,13 +33,20 @@ class Row implements ArrayAccess
|
||||
protected $rowCache;
|
||||
|
||||
/**
|
||||
* @param SpreadsheetRow $row
|
||||
* @param array $headingRow
|
||||
* @var bool|null
|
||||
*/
|
||||
public function __construct(SpreadsheetRow $row, array $headingRow = [])
|
||||
protected $rowCacheFormatData;
|
||||
|
||||
/**
|
||||
* @param SpreadsheetRow $row
|
||||
* @param array $headingRow
|
||||
* @param array $headerIsGrouped
|
||||
*/
|
||||
public function __construct(SpreadsheetRow $row, array $headingRow = [], array $headerIsGrouped = [])
|
||||
{
|
||||
$this->row = $row;
|
||||
$this->headingRow = $headingRow;
|
||||
$this->row = $row;
|
||||
$this->headingRow = $headingRow;
|
||||
$this->headerIsGrouped = $headerIsGrouped;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,12 +58,10 @@ class Row implements ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
*
|
||||
* @param string|null $endColumn
|
||||
*
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
* @param string|null $endColumn
|
||||
* @return Collection
|
||||
*/
|
||||
public function toCollection($nullValue = null, $calculateFormulas = false, $formatData = true, ?string $endColumn = null): Collection
|
||||
@@ -64,16 +70,15 @@ class Row implements ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
* @param string|null $endColumn
|
||||
*
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
* @param string|null $endColumn
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($nullValue = null, $calculateFormulas = false, $formatData = true, ?string $endColumn = null)
|
||||
{
|
||||
if (is_array($this->rowCache)) {
|
||||
if (is_array($this->rowCache) && ($this->rowCacheFormatData === $formatData)) {
|
||||
return $this->rowCache;
|
||||
}
|
||||
|
||||
@@ -84,7 +89,11 @@ class Row implements ArrayAccess
|
||||
$value = (new Cell($cell))->getValue($nullValue, $calculateFormulas, $formatData);
|
||||
|
||||
if (isset($this->headingRow[$i])) {
|
||||
$cells[$this->headingRow[$i]] = $value;
|
||||
if (!$this->headerIsGrouped[$i]) {
|
||||
$cells[$this->headingRow[$i]] = $value;
|
||||
} else {
|
||||
$cells[$this->headingRow[$i]][] = $value;
|
||||
}
|
||||
} else {
|
||||
$cells[] = $value;
|
||||
}
|
||||
@@ -96,17 +105,20 @@ class Row implements ArrayAccess
|
||||
$cells = ($this->preparationCallback)($cells, $this->row->getRowIndex());
|
||||
}
|
||||
|
||||
$this->rowCache = $cells;
|
||||
$this->rowCache = $cells;
|
||||
$this->rowCacheFormatData = $formatData;
|
||||
|
||||
return $cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $calculateFormulas
|
||||
* @param string|null $endColumn
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty(): bool
|
||||
public function isEmpty($calculateFormulas = false, ?string $endColumn = null): bool
|
||||
{
|
||||
return count(array_filter($this->toArray(null, false, false))) === 0;
|
||||
return count(array_filter($this->toArray(null, $calculateFormulas, false, $endColumn))) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,28 +129,33 @@ class Row implements ArrayAccess
|
||||
return $this->row->getRowIndex();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetExists($offset)
|
||||
{
|
||||
return isset(($this->toArray())[$offset]);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
return ($this->toArray())[$offset];
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetSet($offset, $value)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function offsetUnset($offset)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Closure $preparationCallback
|
||||
* @param \Closure $preparationCallback
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function setPreparationCallback(Closure $preparationCallback = null)
|
||||
|
162
vendor/maatwebsite/excel/src/Sheet.php
vendored
162
vendor/maatwebsite/excel/src/Sheet.php
vendored
@@ -58,6 +58,7 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
/** @mixin Worksheet */
|
||||
class Sheet
|
||||
{
|
||||
use DelegatedMacroable, HasEventBus;
|
||||
@@ -83,7 +84,7 @@ class Sheet
|
||||
private $worksheet;
|
||||
|
||||
/**
|
||||
* @param Worksheet $worksheet
|
||||
* @param Worksheet $worksheet
|
||||
*/
|
||||
public function __construct(Worksheet $worksheet)
|
||||
{
|
||||
@@ -93,9 +94,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param string|int $index
|
||||
*
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param string|int $index
|
||||
* @return Sheet
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
@@ -111,9 +111,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param int $index
|
||||
*
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param int $index
|
||||
* @return Sheet
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
@@ -129,9 +128,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param string $name
|
||||
*
|
||||
* @param Spreadsheet $spreadsheet
|
||||
* @param string $name
|
||||
* @return Sheet
|
||||
*
|
||||
* @throws SheetNotFoundException
|
||||
@@ -146,7 +144,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $sheetExport
|
||||
* @param object $sheetExport
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
@@ -201,7 +199,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $sheetExport
|
||||
* @param object $sheetExport
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
@@ -238,8 +236,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param int $startRow
|
||||
* @param object $import
|
||||
* @param int $startRow
|
||||
*/
|
||||
public function import($import, int $startRow = 1)
|
||||
{
|
||||
@@ -268,7 +266,7 @@ class Sheet
|
||||
$rows = $this->toCollection($import, $startRow, null, $calculatesFormulas, $formatData);
|
||||
|
||||
if ($import instanceof WithValidation) {
|
||||
$this->validate($import, $startRow, $rows);
|
||||
$rows = $this->validated($import, $startRow, $rows);
|
||||
}
|
||||
|
||||
$import->collection($rows);
|
||||
@@ -278,7 +276,7 @@ class Sheet
|
||||
$rows = $this->toArray($import, $startRow, null, $calculatesFormulas, $formatData);
|
||||
|
||||
if ($import instanceof WithValidation) {
|
||||
$this->validate($import, $startRow, $rows);
|
||||
$rows = $this->validated($import, $startRow, $rows);
|
||||
}
|
||||
|
||||
$import->array($rows);
|
||||
@@ -287,15 +285,19 @@ class Sheet
|
||||
|
||||
if ($import instanceof OnEachRow) {
|
||||
$headingRow = HeadingRowExtractor::extract($this->worksheet, $import);
|
||||
$headerIsGrouped = HeadingRowExtractor::extractGrouping($headingRow, $import);
|
||||
$endColumn = $import instanceof WithColumnLimit ? $import->endColumn() : null;
|
||||
$preparationCallback = $this->getPreparationCallback($import);
|
||||
|
||||
foreach ($this->worksheet->getRowIterator()->resetStart($startRow ?? 1) as $row) {
|
||||
$sheetRow = new Row($row, $headingRow);
|
||||
$sheetRow = new Row($row, $headingRow, $headerIsGrouped);
|
||||
|
||||
if (!$import instanceof SkipsEmptyRows || ($import instanceof SkipsEmptyRows && !$sheetRow->isEmpty())) {
|
||||
if ($import instanceof WithValidation) {
|
||||
$sheetRow->setPreparationCallback($preparationCallback);
|
||||
}
|
||||
|
||||
if (!$import instanceof SkipsEmptyRows || ($import instanceof SkipsEmptyRows && !$sheetRow->isEmpty($calculatesFormulas))) {
|
||||
if ($import instanceof WithValidation) {
|
||||
$sheetRow->setPreparationCallback($preparationCallback);
|
||||
$toValidate = [$sheetRow->getIndex() => $sheetRow->toArray(null, $import instanceof WithCalculatedFormulas, $import instanceof WithFormatData, $endColumn)];
|
||||
|
||||
try {
|
||||
@@ -322,12 +324,11 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param int|null $startRow
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
*
|
||||
* @param object $import
|
||||
* @param int|null $startRow
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($import, int $startRow = null, $nullValue = null, $calculateFormulas = false, $formatData = false)
|
||||
@@ -336,20 +337,25 @@ class Sheet
|
||||
return [];
|
||||
}
|
||||
|
||||
$endRow = EndRowFinder::find($import, $startRow, $this->worksheet->getHighestRow());
|
||||
$headingRow = HeadingRowExtractor::extract($this->worksheet, $import);
|
||||
$endColumn = $import instanceof WithColumnLimit ? $import->endColumn() : null;
|
||||
$endRow = EndRowFinder::find($import, $startRow, $this->worksheet->getHighestRow());
|
||||
$headingRow = HeadingRowExtractor::extract($this->worksheet, $import);
|
||||
$headerIsGrouped = HeadingRowExtractor::extractGrouping($headingRow, $import);
|
||||
$endColumn = $import instanceof WithColumnLimit ? $import->endColumn() : null;
|
||||
|
||||
$rows = [];
|
||||
foreach ($this->worksheet->getRowIterator($startRow, $endRow) as $index => $row) {
|
||||
$row = new Row($row, $headingRow);
|
||||
$row = new Row($row, $headingRow, $headerIsGrouped);
|
||||
|
||||
if ($import instanceof SkipsEmptyRows && $row->isEmpty()) {
|
||||
if ($import instanceof SkipsEmptyRows && $row->isEmpty($calculateFormulas, $endColumn)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$row = $row->toArray($nullValue, $calculateFormulas, $formatData, $endColumn);
|
||||
|
||||
if ($import && method_exists($import, 'isEmptyWhen') && $import->isEmptyWhen($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($import instanceof WithMapping) {
|
||||
$row = $import->map($row);
|
||||
}
|
||||
@@ -369,12 +375,11 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $import
|
||||
* @param int|null $startRow
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
*
|
||||
* @param object $import
|
||||
* @param int|null $startRow
|
||||
* @param null $nullValue
|
||||
* @param bool $calculateFormulas
|
||||
* @param bool $formatData
|
||||
* @return Collection
|
||||
*/
|
||||
public function toCollection($import, int $startRow = null, $nullValue = null, $calculateFormulas = false, $formatData = false): Collection
|
||||
@@ -387,7 +392,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $sheetExport
|
||||
* @param object $sheetExport
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
@@ -430,8 +435,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromView $sheetExport
|
||||
* @param int|null $sheetIndex
|
||||
* @param FromView $sheetExport
|
||||
* @param int|null $sheetIndex
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
*/
|
||||
@@ -453,8 +458,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromQuery $sheetExport
|
||||
* @param Worksheet $worksheet
|
||||
* @param FromQuery $sheetExport
|
||||
* @param Worksheet $worksheet
|
||||
*/
|
||||
public function fromQuery(FromQuery $sheetExport, Worksheet $worksheet)
|
||||
{
|
||||
@@ -464,7 +469,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromCollection $sheetExport
|
||||
* @param FromCollection $sheetExport
|
||||
*/
|
||||
public function fromCollection(FromCollection $sheetExport)
|
||||
{
|
||||
@@ -472,7 +477,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromArray $sheetExport
|
||||
* @param FromArray $sheetExport
|
||||
*/
|
||||
public function fromArray(FromArray $sheetExport)
|
||||
{
|
||||
@@ -480,7 +485,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromIterator $sheetExport
|
||||
* @param FromIterator $sheetExport
|
||||
*/
|
||||
public function fromIterator(FromIterator $sheetExport)
|
||||
{
|
||||
@@ -488,7 +493,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FromGenerator $sheetExport
|
||||
* @param FromGenerator $sheetExport
|
||||
*/
|
||||
public function fromGenerator(FromGenerator $sheetExport)
|
||||
{
|
||||
@@ -496,9 +501,9 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rows
|
||||
* @param string|null $startCell
|
||||
* @param bool $strictNullComparison
|
||||
* @param array $rows
|
||||
* @param string|null $startCell
|
||||
* @param bool $strictNullComparison
|
||||
*/
|
||||
public function append(array $rows, string $startCell = null, bool $strictNullComparison = false)
|
||||
{
|
||||
@@ -526,22 +531,29 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $column
|
||||
* @param string $format
|
||||
* @param string $column
|
||||
* @param string $format
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function formatColumn(string $column, string $format)
|
||||
{
|
||||
$this->worksheet
|
||||
->getStyle($column . '1:' . $column . $this->worksheet->getHighestRow())
|
||||
->getNumberFormat()
|
||||
->setFormatCode($format);
|
||||
// If the column is a range, we wouldn't need to calculate the range.
|
||||
if (stripos($column, ':') !== false) {
|
||||
$this->worksheet
|
||||
->getStyle($column)
|
||||
->getNumberFormat()
|
||||
->setFormatCode($format);
|
||||
} else {
|
||||
$this->worksheet
|
||||
->getStyle($column . '1:' . $column . $this->worksheet->getHighestRow())
|
||||
->getNumberFormat()
|
||||
->setFormatCode($format);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chunkSize
|
||||
*
|
||||
* @param int $chunkSize
|
||||
* @return Sheet
|
||||
*/
|
||||
public function chunkSize(int $chunkSize)
|
||||
@@ -560,7 +572,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Chart|Chart[] $charts
|
||||
* @param Chart|Chart[] $charts
|
||||
*/
|
||||
public function addCharts($charts)
|
||||
{
|
||||
@@ -572,7 +584,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param BaseDrawing|BaseDrawing[] $drawings
|
||||
* @param BaseDrawing|BaseDrawing[] $drawings
|
||||
*/
|
||||
public function addDrawings($drawings)
|
||||
{
|
||||
@@ -584,8 +596,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $concern
|
||||
*
|
||||
* @param string $concern
|
||||
* @return string
|
||||
*/
|
||||
public function hasConcern(string $concern): string
|
||||
@@ -594,8 +605,8 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable $rows
|
||||
* @param object $sheetExport
|
||||
* @param iterable $rows
|
||||
* @param object $sheetExport
|
||||
*/
|
||||
public function appendRows($rows, $sheetExport)
|
||||
{
|
||||
@@ -625,8 +636,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $row
|
||||
*
|
||||
* @param mixed $row
|
||||
* @return array
|
||||
*/
|
||||
public static function mapArraybleRow($row): array
|
||||
@@ -651,7 +661,6 @@ class Sheet
|
||||
|
||||
/**
|
||||
* @param $sheetImport
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStartRow($sheetImport): int
|
||||
@@ -668,7 +677,10 @@ class Sheet
|
||||
unset($this->worksheet);
|
||||
}
|
||||
|
||||
protected function validate(WithValidation $import, int $startRow, $rows)
|
||||
/**
|
||||
* @return Collection|array
|
||||
*/
|
||||
protected function validated(WithValidation $import, int $startRow, $rows)
|
||||
{
|
||||
$toValidate = (new Collection($rows))->mapWithKeys(function ($row, $index) use ($startRow) {
|
||||
return [($startRow + $index) => $row];
|
||||
@@ -677,13 +689,17 @@ class Sheet
|
||||
try {
|
||||
app(RowValidator::class)->validate($toValidate->toArray(), $import);
|
||||
} catch (RowSkippedException $e) {
|
||||
foreach ($e->skippedRows() as $row) {
|
||||
unset($rows[$row - $startRow]);
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $lower
|
||||
* @param string $upper
|
||||
*
|
||||
* @param string $lower
|
||||
* @param string $upper
|
||||
* @return \Generator
|
||||
*/
|
||||
protected function buildColumnRange(string $lower, string $upper)
|
||||
@@ -708,8 +724,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $sheetExport
|
||||
*
|
||||
* @param object $sheetExport
|
||||
* @return bool
|
||||
*/
|
||||
private function hasStrictNullComparison($sheetExport): bool
|
||||
@@ -722,8 +737,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object|WithCustomChunkSize $export
|
||||
*
|
||||
* @param object|WithCustomChunkSize $export
|
||||
* @return int
|
||||
*/
|
||||
private function getChunkSize($export): int
|
||||
@@ -736,7 +750,7 @@ class Sheet
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object|WithValidation $import
|
||||
* @param object|WithValidation $import
|
||||
* @return Closure|null
|
||||
*/
|
||||
private function getPreparationCallback($import)
|
||||
|
@@ -12,7 +12,7 @@ class DbTransactionHandler implements TransactionHandler
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @param ConnectionInterface $connection
|
||||
* @param ConnectionInterface $connection
|
||||
*/
|
||||
public function __construct(ConnectionInterface $connection)
|
||||
{
|
||||
@@ -20,10 +20,10 @@ class DbTransactionHandler implements TransactionHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable $callback
|
||||
* @param callable $callback
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke(callable $callback)
|
||||
{
|
||||
|
@@ -5,8 +5,7 @@ namespace Maatwebsite\Excel\Transactions;
|
||||
class NullTransactionHandler implements TransactionHandler
|
||||
{
|
||||
/**
|
||||
* @param callable $callback
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke(callable $callback)
|
||||
|
@@ -5,8 +5,7 @@ namespace Maatwebsite\Excel\Transactions;
|
||||
interface TransactionHandler
|
||||
{
|
||||
/**
|
||||
* @param callable $callback
|
||||
*
|
||||
* @param callable $callback
|
||||
* @return mixed
|
||||
*/
|
||||
public function __invoke(callable $callback);
|
||||
|
@@ -29,7 +29,7 @@ class TransactionManager extends Manager
|
||||
public function createDbDriver()
|
||||
{
|
||||
return new DbTransactionHandler(
|
||||
DB::connection()
|
||||
DB::connection(config('excel.transactions.db.connection'))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -28,10 +28,10 @@ class Failure implements Arrayable, JsonSerializable
|
||||
private $values;
|
||||
|
||||
/**
|
||||
* @param int $row
|
||||
* @param string $attribute
|
||||
* @param array $errors
|
||||
* @param array $values
|
||||
* @param int $row
|
||||
* @param string $attribute
|
||||
* @param array $errors
|
||||
* @param array $values
|
||||
*/
|
||||
public function __construct(int $row, string $attribute, array $errors, array $values = [])
|
||||
{
|
||||
@@ -86,6 +86,7 @@ class Failure implements Arrayable, JsonSerializable
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
|
@@ -17,7 +17,7 @@ class RowValidator
|
||||
private $validator;
|
||||
|
||||
/**
|
||||
* @param Factory $validator
|
||||
* @param Factory $validator
|
||||
*/
|
||||
public function __construct(Factory $validator)
|
||||
{
|
||||
@@ -25,8 +25,8 @@ class RowValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rows
|
||||
* @param WithValidation $import
|
||||
* @param array $rows
|
||||
* @param WithValidation $import
|
||||
*
|
||||
* @throws ValidationException
|
||||
* @throws RowSkippedException
|
||||
@@ -73,8 +73,7 @@ class RowValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WithValidation $import
|
||||
*
|
||||
* @param WithValidation $import
|
||||
* @return array
|
||||
*/
|
||||
private function messages(WithValidation $import): array
|
||||
@@ -85,8 +84,7 @@ class RowValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WithValidation $import
|
||||
*
|
||||
* @param WithValidation $import
|
||||
* @return array
|
||||
*/
|
||||
private function attributes(WithValidation $import): array
|
||||
@@ -97,8 +95,7 @@ class RowValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WithValidation $import
|
||||
*
|
||||
* @param WithValidation $import
|
||||
* @return array
|
||||
*/
|
||||
private function rules(WithValidation $import): array
|
||||
@@ -107,8 +104,7 @@ class RowValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $elements
|
||||
*
|
||||
* @param array $elements
|
||||
* @return array
|
||||
*/
|
||||
private function formatKey(array $elements): array
|
||||
@@ -121,8 +117,7 @@ class RowValidator
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|object|callable|array $rules
|
||||
*
|
||||
* @param string|object|callable|array $rules
|
||||
* @return string|array
|
||||
*/
|
||||
private function formatRule($rules)
|
||||
@@ -139,7 +134,7 @@ class RowValidator
|
||||
return $rules;
|
||||
}
|
||||
|
||||
if (Str::contains($rules, 'required_if') && preg_match('/(.*):(.*),(.*)/', $rules, $matches)) {
|
||||
if (Str::contains($rules, 'required_') && preg_match('/(.*):(.*),(.*)/', $rules, $matches)) {
|
||||
$column = Str::startsWith($matches[2], '*.') ? $matches[2] : '*.' . $matches[2];
|
||||
|
||||
return $matches[1] . ':' . $column . ',' . $matches[3];
|
||||
|
@@ -12,8 +12,8 @@ class ValidationException extends IlluminateValidationException
|
||||
protected $failures;
|
||||
|
||||
/**
|
||||
* @param IlluminateValidationException $previous
|
||||
* @param array $failures
|
||||
* @param IlluminateValidationException $previous
|
||||
* @param array $failures
|
||||
*/
|
||||
public function __construct(IlluminateValidationException $previous, array $failures)
|
||||
{
|
||||
|
72
vendor/maatwebsite/excel/src/Writer.php
vendored
72
vendor/maatwebsite/excel/src/Writer.php
vendored
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace Maatwebsite\Excel;
|
||||
|
||||
use Maatwebsite\Excel\Cache\CacheManager;
|
||||
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;
|
||||
@@ -17,7 +18,10 @@ 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;
|
||||
@@ -38,7 +42,7 @@ class Writer
|
||||
protected $temporaryFileFactory;
|
||||
|
||||
/**
|
||||
* @param TemporaryFileFactory $temporaryFileFactory
|
||||
* @param TemporaryFileFactory $temporaryFileFactory
|
||||
*/
|
||||
public function __construct(TemporaryFileFactory $temporaryFileFactory)
|
||||
{
|
||||
@@ -48,10 +52,10 @@ class Writer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
*
|
||||
* @param object $export
|
||||
* @param string $writerType
|
||||
* @return TemporaryFile
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function export($export, string $writerType): TemporaryFile
|
||||
@@ -71,8 +75,7 @@ class Writer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
*
|
||||
* @param object $export
|
||||
* @return $this
|
||||
*/
|
||||
public function open($export)
|
||||
@@ -93,16 +96,42 @@ class Writer
|
||||
|
||||
$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
|
||||
*
|
||||
* @param TemporaryFile $tempFile
|
||||
* @param string $writerType
|
||||
* @return Writer
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
|
||||
*/
|
||||
public function reopen(TemporaryFile $tempFile, string $writerType)
|
||||
@@ -114,11 +143,11 @@ class Writer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
*
|
||||
* @param object $export
|
||||
* @param TemporaryFile $temporaryFile
|
||||
* @param string $writerType
|
||||
* @return TemporaryFile
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
@@ -142,20 +171,20 @@ class Writer
|
||||
|
||||
if ($temporaryFile instanceof RemoteTemporaryFile) {
|
||||
$temporaryFile->updateRemote();
|
||||
$temporaryFile->deleteLocalCopy();
|
||||
}
|
||||
|
||||
$this->clearListeners();
|
||||
$this->spreadsheet->disconnectWorksheets();
|
||||
unset($this->spreadsheet);
|
||||
app(CacheManager::class)->flush();
|
||||
|
||||
return $temporaryFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $sheetIndex
|
||||
*
|
||||
* @param int|null $sheetIndex
|
||||
* @return Sheet
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function addNewSheet(int $sheetIndex = null)
|
||||
@@ -184,9 +213,9 @@ class Writer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $sheetIndex
|
||||
*
|
||||
* @param int $sheetIndex
|
||||
* @return Sheet
|
||||
*
|
||||
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||
*/
|
||||
public function getSheetByIndex(int $sheetIndex)
|
||||
@@ -195,8 +224,7 @@ class Writer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $concern
|
||||
*
|
||||
* @param string $concern
|
||||
* @return bool
|
||||
*/
|
||||
public function hasConcern($concern): bool
|
||||
@@ -205,7 +233,7 @@ class Writer
|
||||
}
|
||||
|
||||
/**
|
||||
* @param object $export
|
||||
* @param object $export
|
||||
*/
|
||||
protected function handleDocumentProperties($export)
|
||||
{
|
||||
|
Reference in New Issue
Block a user