repo stringlengths 7 63 | file_url stringlengths 81 284 | file_path stringlengths 5 200 | content stringlengths 0 32.8k | language stringclasses 1 value | license stringclasses 7 values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:02:33 2026-01-05 05:24:06 | truncated bool 2 classes |
|---|---|---|---|---|---|---|---|---|
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Transactions/NullTransactionHandler.php | src/Transactions/NullTransactionHandler.php | <?php
namespace Maatwebsite\Excel\Transactions;
class NullTransactionHandler implements TransactionHandler
{
/**
* @param callable $callback
* @return mixed
*/
public function __invoke(callable $callback)
{
return $callback();
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Transactions/TransactionManager.php | src/Transactions/TransactionManager.php | <?php
namespace Maatwebsite\Excel\Transactions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Manager;
class TransactionManager extends Manager
{
/**
* @return string
*/
public function getDefaultDriver()
{
return config('excel.transactions.handler');
}
/**
* @return NullTransactionHandler
*/
public function createNullDriver()
{
return new NullTransactionHandler();
}
/**
* @return DbTransactionHandler
*/
public function createDbDriver()
{
return new DbTransactionHandler(
DB::connection(config('excel.transactions.db.connection'))
);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Cache/BatchCacheDeprecated.php | src/Cache/BatchCacheDeprecated.php | <?php
namespace Maatwebsite\Excel\Cache;
use Illuminate\Support\Facades\Cache;
use Psr\SimpleCache\CacheInterface;
class BatchCacheDeprecated implements CacheInterface
{
/**
* @var CacheInterface
*/
protected $cache;
/**
* @var MemoryCacheDeprecated
*/
protected $memory;
/**
* @var null|int|\DateTimeInterface|callable
*/
protected $defaultTTL = null;
/**
* @param CacheInterface $cache
* @param MemoryCacheDeprecated $memory
* @param int|\DateTimeInterface|callable|null $defaultTTL
*/
public function __construct(
CacheInterface $cache,
MemoryCacheDeprecated $memory,
$defaultTTL = null
) {
$this->cache = $cache;
$this->memory = $memory;
$this->defaultTTL = $defaultTTL;
}
public function __sleep()
{
return ['memory'];
}
public function __wakeup()
{
$this->cache = Cache::driver(
config('excel.cache.illuminate.store')
);
}
/**
* {@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)
{
if (func_num_args() === 2) {
$ttl = value($this->defaultTTL);
}
$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)
{
if (func_num_args() === 1) {
$ttl = value($this->defaultTTL);
}
$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);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Cache/MemoryCacheDeprecated.php | src/Cache/MemoryCacheDeprecated.php | <?php
namespace Maatwebsite\Excel\Cache;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
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;
foreach ($memory as $cell) {
if ($cell instanceof Cell) {
$cell->detach();
}
}
$this->clear();
return $memory;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Cache/BatchCache.php | src/Cache/BatchCache.php | <?php
namespace Maatwebsite\Excel\Cache;
use Illuminate\Support\Facades\Cache;
use Psr\SimpleCache\CacheInterface;
class BatchCache implements CacheInterface
{
/**
* @var CacheInterface
*/
protected $cache;
/**
* @var MemoryCache
*/
protected $memory;
/**
* @var null|int|\DateInterval|callable
*/
protected $defaultTTL = null;
/**
* @param CacheInterface $cache
* @param MemoryCache $memory
* @param null|int|\DateInterval|callable $defaultTTL
*/
public function __construct(
CacheInterface $cache,
MemoryCache $memory,
null|int|\DateInterval|callable $defaultTTL = null
) {
$this->cache = $cache;
$this->memory = $memory;
$this->defaultTTL = $defaultTTL;
}
public function __sleep()
{
return ['memory'];
}
public function __wakeup()
{
$this->cache = Cache::driver(
config('excel.cache.illuminate.store')
);
}
/**
* {@inheritdoc}
*/
public function get(string $key, mixed $default = null): mixed
{
if ($this->memory->has($key)) {
return $this->memory->get($key);
}
return $this->cache->get($key, $default);
}
/**
* {@inheritdoc}
*/
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
{
if (func_num_args() === 2) {
$ttl = value($this->defaultTTL);
}
$this->memory->set($key, $value, $ttl);
if ($this->memory->reachedMemoryLimit()) {
return $this->cache->setMultiple($this->memory->flush(), $ttl);
}
return true;
}
/**
* {@inheritdoc}
*/
public function delete(string $key): bool
{
if ($this->memory->has($key)) {
return $this->memory->delete($key);
}
return $this->cache->delete($key);
}
/**
* {@inheritdoc}
*/
public function clear(): bool
{
$this->memory->clear();
return $this->cache->clear();
}
/**
* {@inheritdoc}
*/
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
// 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(iterable $values, null|int|\DateInterval $ttl = null): bool
{
if (func_num_args() === 1) {
$ttl = value($this->defaultTTL);
}
$this->memory->setMultiple($values, $ttl);
if ($this->memory->reachedMemoryLimit()) {
return $this->cache->setMultiple($this->memory->flush(), $ttl);
}
return true;
}
/**
* {@inheritdoc}
*/
public function deleteMultiple(iterable $keys): bool
{
$keys = is_array($keys) ? $keys : iterator_to_array($keys);
$this->memory->deleteMultiple($keys);
return $this->cache->deleteMultiple($keys);
}
/**
* {@inheritdoc}
*/
public function has(string $key): bool
{
if ($this->memory->has($key)) {
return true;
}
return $this->cache->has($key);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Cache/MemoryCache.php | src/Cache/MemoryCache.php | <?php
namespace Maatwebsite\Excel\Cache;
use PhpOffice\PhpSpreadsheet\Cell\Cell;
use Psr\SimpleCache\CacheInterface;
class MemoryCache 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(): bool
{
$this->cache = [];
return true;
}
/**
* {@inheritdoc}
*/
public function delete(string $key): bool
{
unset($this->cache[$key]);
return true;
}
/**
* {@inheritdoc}
*/
public function deleteMultiple($keys): bool
{
foreach ($keys as $key) {
$this->delete($key);
}
return true;
}
/**
* {@inheritdoc}
*/
public function get(string $key, mixed $default = null): mixed
{
if ($this->has($key)) {
return $this->cache[$key];
}
return $default;
}
/**
* {@inheritdoc}
*/
public function getMultiple(iterable $keys, mixed $default = null): iterable
{
$results = [];
foreach ($keys as $key) {
$results[$key] = $this->get($key, $default);
}
return $results;
}
/**
* {@inheritdoc}
*/
public function has($key): bool
{
return isset($this->cache[$key]);
}
/**
* {@inheritdoc}
*/
public function set(string $key, mixed $value, null|int|\DateInterval $ttl = null): bool
{
$this->cache[$key] = $value;
return true;
}
/**
* {@inheritdoc}
*/
public function setMultiple($values, $ttl = null): bool
{
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;
foreach ($memory as $cell) {
if ($cell instanceof Cell) {
$cell->detach();
}
}
$this->clear();
return $memory;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Cache/CacheManager.php | src/Cache/CacheManager.php | <?php
namespace Maatwebsite\Excel\Cache;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Manager;
use Psr\SimpleCache\CacheInterface;
class CacheManager extends Manager
{
/**
* @const string
*/
public const DRIVER_BATCH = 'batch';
/**
* @const string
*/
public const DRIVER_MEMORY = 'memory';
/**
* @const string
*/
public const DRIVER_ILLUMINATE = 'illuminate';
/**
* Get the default driver name.
*
* @return string
*/
public function getDefaultDriver(): string
{
return config('excel.cache.driver', 'memory');
}
/**
* @return MemoryCache
*/
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)
);
}
/**
* @return BatchCache
*/
public function createBatchDriver(): CacheInterface
{
if (!InstalledVersions::satisfies(new VersionParser, 'psr/simple-cache', '^3.0')) {
return new BatchCacheDeprecated(
$this->createIlluminateDriver(),
$this->createMemoryDriver(),
config('excel.cache.default_ttl')
);
}
return new BatchCache(
$this->createIlluminateDriver(),
$this->createMemoryDriver(),
config('excel.cache.default_ttl')
);
}
/**
* @return CacheInterface
*/
public function createIlluminateDriver(): CacheInterface
{
return Cache::driver(
config('excel.cache.illuminate.store')
);
}
public function flush()
{
$this->driver()->clear();
}
public function isInMemory(): bool
{
return $this->getDefaultDriver() === self::DRIVER_MEMORY;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Facades/Excel.php | src/Facades/Excel.php | <?php
namespace Maatwebsite\Excel\Facades;
use Illuminate\Foundation\Bus\PendingDispatch;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Facade;
use Maatwebsite\Excel\Excel as BaseExcel;
use Maatwebsite\Excel\Fakes\ExcelFake;
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)
* @method static PendingDispatch queueImport(object $import, string|UploadedFile $filePath, string $disk = null, string $readerType = null)
* @method static void matchByRegex()
* @method static void doNotMatchByRegex()
* @method static void assertDownloaded(string $fileName, callable $callback = null)
* @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
{
/**
* Replace the bound instance with a fake.
*
* @return void
*/
public static function fake()
{
static::swap(new ExcelFake());
}
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'excel';
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Console/ExportMakeCommand.php | src/Console/ExportMakeCommand.php | <?php
namespace Maatwebsite\Excel\Console;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
class ExportMakeCommand extends GeneratorCommand
{
use WithModelStub;
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:export';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new export class';
/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Export';
/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
if ($this->option('model') && $this->option('query')) {
return $this->resolveStubPath('/stubs/export.query-model.stub');
} elseif ($this->option('model')) {
return $this->resolveStubPath('/stubs/export.model.stub');
} elseif ($this->option('query')) {
return $this->resolveStubPath('/stubs/export.query.stub');
}
return $this->resolveStubPath('/stubs/export.plain.stub');
}
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace . '\Exports';
}
/**
* Build the class with the given name.
* Remove the base controller import if we are already in base namespace.
*
* @param string $name
* @return string
*/
protected function buildClass($name)
{
$replace = [];
if ($this->option('model')) {
$replace = $this->buildModelReplacements($replace);
}
return str_replace(
array_keys($replace), array_values($replace), parent::buildClass($name)
);
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['model', 'm', InputOption::VALUE_OPTIONAL, 'Generate an export for the given model.'],
['query', '', InputOption::VALUE_NONE, 'Generate an export for a query.'],
];
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Console/ImportMakeCommand.php | src/Console/ImportMakeCommand.php | <?php
namespace Maatwebsite\Excel\Console;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;
class ImportMakeCommand extends GeneratorCommand
{
use WithModelStub;
/**
* The console command name.
*
* @var string
*/
protected $name = 'make:import';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new import class';
/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'Import';
/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return $this->option('model')
? $this->resolveStubPath('/stubs/import.model.stub')
: $this->resolveStubPath('/stubs/import.collection.stub');
}
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace . '\Imports';
}
/**
* Build the class with the given name.
* Remove the base controller import if we are already in base namespace.
*
* @param string $name
* @return string
*/
protected function buildClass($name)
{
$replace = [];
if ($this->option('model')) {
$replace = $this->buildModelReplacements($replace);
}
return str_replace(
array_keys($replace), array_values($replace), parent::buildClass($name)
);
}
/**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return [
['model', 'm', InputOption::VALUE_OPTIONAL, 'Generate an import for the given model.'],
];
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Console/WithModelStub.php | src/Console/WithModelStub.php | <?php
namespace Maatwebsite\Excel\Console;
use Illuminate\Support\Str;
use InvalidArgumentException;
trait WithModelStub
{
/**
* Build the model replacement values.
*
* @param array $replace
* @return array
*/
protected function buildModelReplacements(array $replace): array
{
$modelClass = $this->parseModel($this->option('model'));
return array_merge($replace, [
'DummyFullModelClass' => $modelClass,
'DummyModelClass' => class_basename($modelClass),
]);
}
/**
* Get the fully-qualified model class name.
*
* @param string $model
* @return string
*/
protected function parseModel($model): string
{
if (preg_match('([^A-Za-z0-9_/\\\\])', $model)) {
throw new InvalidArgumentException('Model name contains invalid characters.');
}
$model = ltrim($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;
}
/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
* @return string
*/
protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__ . $stub;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Middleware/ConvertEmptyCellValuesToNull.php | src/Middleware/ConvertEmptyCellValuesToNull.php | <?php
namespace Maatwebsite\Excel\Middleware;
class ConvertEmptyCellValuesToNull extends CellMiddleware
{
/**
* @param mixed $value
* @return mixed
*/
public function __invoke($value, callable $next)
{
return $next(
$value === '' ? null : $value
);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Middleware/CellMiddleware.php | src/Middleware/CellMiddleware.php | <?php
namespace Maatwebsite\Excel\Middleware;
abstract class CellMiddleware
{
/**
* @param mixed $value
* @return mixed
*/
abstract public function __invoke($value, callable $next);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Middleware/TrimCellValue.php | src/Middleware/TrimCellValue.php | <?php
namespace Maatwebsite\Excel\Middleware;
class TrimCellValue extends CellMiddleware
{
/**
* @param mixed $value
* @return mixed
*/
public function __invoke($value, callable $next)
{
if (!is_string($value)) {
return $next($value);
}
// Remove whitespace, BOM and zero width spaces.
$cleaned = preg_replace('~^[\s\x{FEFF}\x{200B}]+|[\s\x{FEFF}\x{200B}]+$~u', '', $value) ?? trim($value);
return $next($cleaned);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithChunkReading.php | src/Concerns/WithChunkReading.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithChunkReading
{
/**
* @return int
*/
public function chunkSize(): int;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/SkipsUnknownSheets.php | src/Concerns/SkipsUnknownSheets.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface SkipsUnknownSheets
{
/**
* @param string|int $sheetName
*/
public function onUnknownSheet($sheetName);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithBatchInserts.php | src/Concerns/WithBatchInserts.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithBatchInserts
{
/**
* @return int
*/
public function batchSize(): int;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/SkipsErrors.php | src/Concerns/SkipsErrors.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
use Throwable;
trait SkipsErrors
{
/**
* @var Throwable[]
*/
protected $errors = [];
/**
* @param Throwable $e
*/
public function onError(Throwable $e)
{
$this->errors[] = $e;
}
/**
* @return Throwable[]|Collection
*/
public function errors(): Collection
{
return new Collection($this->errors);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/ToCollection.php | src/Concerns/ToCollection.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
interface ToCollection
{
/**
* @param Collection $collection
*/
public function collection(Collection $collection);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/MapsCsvSettings.php | src/Concerns/MapsCsvSettings.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Arr;
trait MapsCsvSettings
{
/**
* @var string
*/
protected static $delimiter = ',';
/**
* @var string
*/
protected static $enclosure = '"';
/**
* @var string
*/
protected static $lineEnding = PHP_EOL;
/**
* @var bool
*/
protected static $useBom = false;
/**
* @var bool
*/
protected static $includeSeparatorLine = false;
/**
* @var bool
*/
protected static $excelCompatibility = false;
/**
* @var string
*/
protected static $escapeCharacter = '\\';
/**
* @var bool
*/
protected static $contiguous = false;
/**
* @var string
*/
protected static $inputEncoding = 'UTF-8';
/**
* @var string
*/
protected static $outputEncoding = '';
/**
* @var bool
*/
protected static $testAutoDetect = true;
/**
* @param array $config
*/
public static function applyCsvSettings(array $config)
{
static::$delimiter = Arr::get($config, 'delimiter', static::$delimiter);
static::$enclosure = Arr::get($config, 'enclosure', static::$enclosure);
static::$lineEnding = Arr::get($config, 'line_ending', static::$lineEnding);
static::$useBom = Arr::get($config, 'use_bom', static::$useBom);
static::$includeSeparatorLine = Arr::get($config, 'include_separator_line', static::$includeSeparatorLine);
static::$excelCompatibility = Arr::get($config, 'excel_compatibility', static::$excelCompatibility);
static::$escapeCharacter = Arr::get($config, 'escape_character', static::$escapeCharacter);
static::$contiguous = Arr::get($config, 'contiguous', static::$contiguous);
static::$inputEncoding = Arr::get($config, 'input_encoding', static::$inputEncoding);
static::$outputEncoding = Arr::get($config, 'output_encoding', static::$outputEncoding);
static::$testAutoDetect = Arr::get($config, 'test_auto_detect', static::$testAutoDetect);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCustomValueBinder.php | src/Concerns/WithCustomValueBinder.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Cell\IValueBinder;
interface WithCustomValueBinder extends IValueBinder
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/FromIterator.php | src/Concerns/FromIterator.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Iterator;
interface FromIterator
{
/**
* @return Iterator
*/
public function iterator(): Iterator;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCustomStartCell.php | src/Concerns/WithCustomStartCell.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomStartCell
{
/**
* @return string
*/
public function startCell(): string;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/FromGenerator.php | src/Concerns/FromGenerator.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Generator;
interface FromGenerator
{
/**
* @return Generator
*/
public function generator(): Generator;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithGroupedHeadingRow.php | src/Concerns/WithGroupedHeadingRow.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithGroupedHeadingRow extends WithHeadingRow
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/FromView.php | src/Concerns/FromView.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Contracts\View\View;
interface FromView
{
/**
* @return View
*/
public function view(): View;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/SkipsFailures.php | src/Concerns/SkipsFailures.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Validators\Failure;
trait SkipsFailures
{
/**
* @var Failure[]
*/
protected $failures = [];
/**
* @param Failure ...$failures
*/
public function onFailure(Failure ...$failures)
{
$this->failures = array_merge($this->failures, $failures);
}
/**
* @return Failure[]|Collection
*/
public function failures(): Collection
{
return new Collection($this->failures);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithHeadingRow.php | src/Concerns/WithHeadingRow.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithHeadingRow
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithStrictNullComparison.php | src/Concerns/WithStrictNullComparison.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithStrictNullComparison
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithMapping.php | src/Concerns/WithMapping.php | <?php
namespace Maatwebsite\Excel\Concerns;
/**
* @template RowType of mixed
*/
interface WithMapping
{
/**
* @param RowType $row
* @return array
*/
public function map($row): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithReadFilter.php | src/Concerns/WithReadFilter.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
interface WithReadFilter
{
/**
* @return IReadFilter
*/
public function readFilter(): IReadFilter;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/FromQuery.php | src/Concerns/FromQuery.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Query\Builder;
use Laravel\Scout\Builder as ScoutBuilder;
interface FromQuery
{
/**
* @return Builder|EloquentBuilder|Relation|ScoutBuilder
*/
public function query();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithConditionalSheets.php | src/Concerns/WithConditionalSheets.php | <?php
namespace Maatwebsite\Excel\Concerns;
trait WithConditionalSheets
{
/**
* @var array
*/
protected $conditionallySelectedSheets = [];
/**
* @param string|array $sheets
* @return $this
*/
public function onlySheets($sheets)
{
$this->conditionallySelectedSheets = is_array($sheets) ? $sheets : func_get_args();
return $this;
}
/**
* @return array
*/
public function sheets(): array
{
return \array_filter($this->conditionalSheets(), function ($name) {
return \in_array($name, $this->conditionallySelectedSheets, false);
}, ARRAY_FILTER_USE_KEY);
}
/**
* @return array
*/
abstract public function conditionalSheets(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/SkipsOnFailure.php | src/Concerns/SkipsOnFailure.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Maatwebsite\Excel\Validators\Failure;
interface SkipsOnFailure
{
/**
* @param Failure[] $failures
*/
public function onFailure(Failure ...$failures);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithColumnWidths.php | src/Concerns/WithColumnWidths.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithColumnWidths
{
public function columnWidths(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithEvents.php | src/Concerns/WithEvents.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithEvents
{
/**
* @return array
*/
public function registerEvents(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithUpserts.php | src/Concerns/WithUpserts.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithUpserts
{
/**
* @return string|array
*/
public function uniqueBy();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/Exportable.php | src/Concerns/Exportable.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Foundation\Bus\PendingDispatch;
use Maatwebsite\Excel\Exceptions\NoFilenameGivenException;
use Maatwebsite\Excel\Exceptions\NoFilePathGivenException;
use Maatwebsite\Excel\Exporter;
trait Exportable
{
/**
* @param string $fileName
* @param string|null $writerType
* @param array $headers
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse
*
* @throws NoFilenameGivenException
*/
public function download(?string $fileName = null, ?string $writerType = null, ?array $headers = null)
{
$headers = $headers ?? $this->headers ?? [];
$fileName = $fileName ?? $this->fileName ?? null;
$writerType = $writerType ?? $this->writerType ?? null;
if (null === $fileName) {
throw new NoFilenameGivenException();
}
return $this->getExporter()->download($this, $fileName, $writerType, $headers);
}
/**
* @param string $filePath
* @param string|null $disk
* @param string|null $writerType
* @param mixed $diskOptions
* @return bool|PendingDispatch
*
* @throws NoFilePathGivenException
*/
public function store(?string $filePath = null, ?string $disk = null, ?string $writerType = null, $diskOptions = [])
{
$filePath = $filePath ?? $this->filePath ?? null;
if (null === $filePath) {
throw NoFilePathGivenException::export();
}
return $this->getExporter()->store(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$writerType ?? $this->writerType ?? null,
$diskOptions ?: $this->diskOptions ?? []
);
}
/**
* @param string|null $filePath
* @param string|null $disk
* @param string|null $writerType
* @param mixed $diskOptions
* @return PendingDispatch
*
* @throws NoFilePathGivenException
*/
public function queue(?string $filePath = null, ?string $disk = null, ?string $writerType = null, $diskOptions = [])
{
$filePath = $filePath ?? $this->filePath ?? null;
if (null === $filePath) {
throw NoFilePathGivenException::export();
}
return $this->getExporter()->queue(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$writerType ?? $this->writerType ?? null,
$diskOptions ?: $this->diskOptions ?? []
);
}
/**
* @param string|null $writerType
* @return string
*/
public function raw($writerType = null)
{
$writerType = $writerType ?? $this->writerType ?? null;
return $this->getExporter()->raw($this, $writerType);
}
/**
* Create an HTTP response that represents the object.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*
* @throws NoFilenameGivenException
*/
public function toResponse($request)
{
return $this->download();
}
/**
* @return Exporter
*/
private function getExporter(): Exporter
{
return app(Exporter::class);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCustomQuerySize.php | src/Concerns/WithCustomQuerySize.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomQuerySize
{
/**
* Queued exportables are processed in chunks; each chunk being a job pushed to the queue by the QueuedWriter.
* In case of exportables that implement the FromQuery concern, the number of jobs is calculated by dividing the $query->count() by the chunk size.
* Depending on the implementation of the query() method (eg. When using a groupBy clause), this calculation might not be correct.
*
* When this is the case, you should use this method to provide a custom calculation of the query size.
*
* @return int
*/
public function querySize(): int;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/RemembersChunkOffset.php | src/Concerns/RemembersChunkOffset.php | <?php
namespace Maatwebsite\Excel\Concerns;
trait RemembersChunkOffset
{
/**
* @var int|null
*/
protected $chunkOffset;
/**
* @param int $chunkOffset
*/
public function setChunkOffset(int $chunkOffset)
{
$this->chunkOffset = $chunkOffset;
}
/**
* @return int|null
*/
public function getChunkOffset()
{
return $this->chunkOffset;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithStartRow.php | src/Concerns/WithStartRow.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithStartRow
{
/**
* @return int
*/
public function startRow(): int;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCharts.php | src/Concerns/WithCharts.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Chart\Chart;
interface WithCharts
{
/**
* @return Chart|Chart[]
*/
public function charts();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithProgressBar.php | src/Concerns/WithProgressBar.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Console\OutputStyle;
interface WithProgressBar
{
/**
* @return OutputStyle
*/
public function getConsoleOutput(): OutputStyle;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithTitle.php | src/Concerns/WithTitle.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithTitle
{
/**
* @return string
*/
public function title(): string;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/ShouldAutoSize.php | src/Concerns/ShouldAutoSize.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface ShouldAutoSize
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCustomCsvSettings.php | src/Concerns/WithCustomCsvSettings.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomCsvSettings
{
/**
* @return array
*/
public function getCsvSettings(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithMultipleSheets.php | src/Concerns/WithMultipleSheets.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithMultipleSheets
{
/**
* @return array
*/
public function sheets(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/OnEachRow.php | src/Concerns/OnEachRow.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Maatwebsite\Excel\Row;
interface OnEachRow
{
/**
* @param Row $row
*/
public function onRow(Row $row);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/RemembersRowNumber.php | src/Concerns/RemembersRowNumber.php | <?php
namespace Maatwebsite\Excel\Concerns;
trait RemembersRowNumber
{
/**
* @var int
*/
protected $rowNumber;
/**
* @param int $rowNumber
*/
public function rememberRowNumber(int $rowNumber)
{
$this->rowNumber = $rowNumber;
}
/**
* @return int|null
*/
public function getRowNumber()
{
return $this->rowNumber;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/HasReferencesToOtherSheets.php | src/Concerns/HasReferencesToOtherSheets.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface HasReferencesToOtherSheets
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithHeadings.php | src/Concerns/WithHeadings.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithHeadings
{
/**
* @return array
*/
public function headings(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithDefaultStyles.php | src/Concerns/WithDefaultStyles.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Style\Style;
interface WithDefaultStyles
{
/**
* @return array|void
*/
public function defaultStyles(Style $defaultStyle);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithStyles.php | src/Concerns/WithStyles.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
interface WithStyles
{
public function styles(Worksheet $sheet);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithValidation.php | src/Concerns/WithValidation.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithValidation
{
/**
* @return array
*/
public function rules(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithUpsertColumns.php | src/Concerns/WithUpsertColumns.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithUpsertColumns
{
/**
* @return array
*/
public function upsertColumns();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/SkipsEmptyRows.php | src/Concerns/SkipsEmptyRows.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface SkipsEmptyRows
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithMappedCells.php | src/Concerns/WithMappedCells.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithMappedCells
{
/**
* @return array
*/
public function mapping(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/Importable.php | src/Concerns/Importable.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Console\OutputStyle;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\PendingDispatch;
use Illuminate\Support\Collection;
use InvalidArgumentException;
use Maatwebsite\Excel\Exceptions\NoFilePathGivenException;
use Maatwebsite\Excel\Importer;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\HttpFoundation\File\UploadedFile;
trait Importable
{
/**
* @var OutputStyle|null
*/
protected $output;
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
* @return Importer|PendingDispatch
*
* @throws NoFilePathGivenException
*/
public function import($filePath = null, ?string $disk = null, ?string $readerType = null)
{
$filePath = $this->getFilePath($filePath);
return $this->getImporter()->import(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$readerType ?? $this->readerType ?? null
);
}
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
* @return array
*
* @throws NoFilePathGivenException
*/
public function toArray($filePath = null, ?string $disk = null, ?string $readerType = null): array
{
$filePath = $this->getFilePath($filePath);
return $this->getImporter()->toArray(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$readerType ?? $this->readerType ?? null
);
}
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
* @return Collection
*
* @throws NoFilePathGivenException
*/
public function toCollection($filePath = null, ?string $disk = null, ?string $readerType = null): Collection
{
$filePath = $this->getFilePath($filePath);
return $this->getImporter()->toCollection(
$this,
$filePath,
$disk ?? $this->disk ?? null,
$readerType ?? $this->readerType ?? null
);
}
/**
* @param string|UploadedFile|null $filePath
* @param string|null $disk
* @param string|null $readerType
* @return PendingDispatch
*
* @throws NoFilePathGivenException
* @throws InvalidArgumentException
*/
public function queue($filePath = null, ?string $disk = null, ?string $readerType = null)
{
if (!$this instanceof ShouldQueue) {
throw new InvalidArgumentException('Importable should implement ShouldQueue to be queued.');
}
return $this->import($filePath, $disk, $readerType);
}
/**
* @param OutputStyle $output
* @return $this
*/
public function withOutput(OutputStyle $output)
{
$this->output = $output;
return $this;
}
/**
* @return OutputStyle
*/
public function getConsoleOutput(): OutputStyle
{
if (!$this->output instanceof OutputStyle) {
$this->output = new OutputStyle(new StringInput(''), new NullOutput());
}
return $this->output;
}
/**
* @param UploadedFile|string|null $filePath
* @return UploadedFile|string
*
* @throws NoFilePathGivenException
*/
private function getFilePath($filePath = null)
{
$filePath = $filePath ?? $this->filePath ?? null;
if (null === $filePath) {
throw NoFilePathGivenException::import();
}
return $filePath;
}
/**
* @return Importer
*/
private function getImporter(): Importer
{
return app(Importer::class);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCustomChunkSize.php | src/Concerns/WithCustomChunkSize.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithCustomChunkSize
{
/**
* @return int
*/
public function chunkSize(): int;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/ToArray.php | src/Concerns/ToArray.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface ToArray
{
/**
* @param array $array
*/
public function array(array $array);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithCalculatedFormulas.php | src/Concerns/WithCalculatedFormulas.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithCalculatedFormulas
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithSkipDuplicates.php | src/Concerns/WithSkipDuplicates.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithSkipDuplicates
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/SkipsOnError.php | src/Concerns/SkipsOnError.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Throwable;
interface SkipsOnError
{
/**
* @param Throwable $e
*/
public function onError(Throwable $e);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/RegistersEventListeners.php | src/Concerns/RegistersEventListeners.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Maatwebsite\Excel\Events\AfterBatch;
use Maatwebsite\Excel\Events\AfterChunk;
use Maatwebsite\Excel\Events\AfterImport;
use Maatwebsite\Excel\Events\AfterSheet;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\BeforeImport;
use Maatwebsite\Excel\Events\BeforeSheet;
use Maatwebsite\Excel\Events\BeforeWriting;
use Maatwebsite\Excel\Events\ImportFailed;
trait RegistersEventListeners
{
/**
* @return array
*/
public function registerEvents(): array
{
$listenersClasses = [
BeforeExport::class => 'beforeExport',
BeforeWriting::class => 'beforeWriting',
BeforeImport::class => 'beforeImport',
AfterImport::class => 'afterImport',
AfterBatch::class => 'afterBatch',
AfterChunk::class => 'afterChunk',
ImportFailed::class => 'importFailed',
BeforeSheet::class => 'beforeSheet',
AfterSheet::class => 'afterSheet',
];
$listeners = [];
foreach ($listenersClasses as $class => $name) {
// Method names are case insensitive in php
if (method_exists($this, $name)) {
// Allow methods to not be static
$listeners[$class] = [$this, $name];
}
}
return $listeners;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/ToModel.php | src/Concerns/ToModel.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Database\Eloquent\Model;
interface ToModel
{
/**
* @param array $row
* @return Model|Model[]|null
*/
public function model(array $row);
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithDrawings.php | src/Concerns/WithDrawings.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Worksheet\BaseDrawing;
interface WithDrawings
{
/**
* @return BaseDrawing|BaseDrawing[]
*/
public function drawings();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/PersistRelations.php | src/Concerns/PersistRelations.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface PersistRelations
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithFormatData.php | src/Concerns/WithFormatData.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithFormatData
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithColumnFormatting.php | src/Concerns/WithColumnFormatting.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithColumnFormatting
{
/**
* @return array
*/
public function columnFormats(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithBackgroundColor.php | src/Concerns/WithBackgroundColor.php | <?php
namespace Maatwebsite\Excel\Concerns;
use PhpOffice\PhpSpreadsheet\Style\Color;
interface WithBackgroundColor
{
/**
* @return string|array|Color
*/
public function backgroundColor();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/FromCollection.php | src/Concerns/FromCollection.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Support\Collection;
interface FromCollection
{
/**
* @return Collection
*/
public function collection();
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithLimit.php | src/Concerns/WithLimit.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithLimit
{
/**
* @return int
*/
public function limit(): int;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithPreCalculateFormulas.php | src/Concerns/WithPreCalculateFormulas.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithPreCalculateFormulas
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/ShouldQueueWithoutChain.php | src/Concerns/ShouldQueueWithoutChain.php | <?php
namespace Maatwebsite\Excel\Concerns;
use Illuminate\Contracts\Queue\ShouldQueue;
interface ShouldQueueWithoutChain extends ShouldQueue
{
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithProperties.php | src/Concerns/WithProperties.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithProperties
{
public function properties(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/FromArray.php | src/Concerns/FromArray.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface FromArray
{
/**
* @return array
*/
public function array(): array;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Concerns/WithColumnLimit.php | src/Concerns/WithColumnLimit.php | <?php
namespace Maatwebsite\Excel\Concerns;
interface WithColumnLimit
{
public function endColumn(): string;
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Validators/RowValidator.php | src/Validators/RowValidator.php | <?php
namespace Maatwebsite\Excel\Validators;
use Illuminate\Contracts\Validation\Factory;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException as IlluminateValidationException;
use Maatwebsite\Excel\Concerns\SkipsOnFailure;
use Maatwebsite\Excel\Concerns\WithValidation;
use Maatwebsite\Excel\Exceptions\RowSkippedException;
class RowValidator
{
/**
* @var Factory
*/
private $validator;
/**
* @param Factory $validator
*/
public function __construct(Factory $validator)
{
$this->validator = $validator;
}
/**
* @param array $rows
* @param WithValidation $import
*
* @throws ValidationException
* @throws RowSkippedException
*/
public function validate(array $rows, WithValidation $import)
{
$rules = $this->rules($import);
$messages = $this->messages($import);
$attributes = $this->attributes($import);
try {
$validator = $this->validator->make($rows, $rules, $messages, $attributes);
if (method_exists($import, 'withValidator')) {
$import->withValidator($validator);
}
$validator->validate();
} catch (IlluminateValidationException $e) {
$failures = [];
foreach ($e->errors() as $attribute => $messages) {
$row = strtok($attribute, '.');
$attributeName = strtok('');
$attributeName = $attributes['*.' . $attributeName] ?? $attributeName;
$failures[] = new Failure(
$row,
$attributeName,
str_replace($attribute, $attributeName, $messages),
$rows[$row] ?? []
);
}
if ($import instanceof SkipsOnFailure) {
$import->onFailure(...$failures);
throw new RowSkippedException(...$failures);
}
throw new ValidationException(
$e,
$failures
);
}
}
/**
* @param WithValidation $import
* @return array
*/
private function messages(WithValidation $import): array
{
return method_exists($import, 'customValidationMessages')
? $this->formatKey($import->customValidationMessages())
: [];
}
/**
* @param WithValidation $import
* @return array
*/
private function attributes(WithValidation $import): array
{
return method_exists($import, 'customValidationAttributes')
? $this->formatKey($import->customValidationAttributes())
: [];
}
/**
* @param WithValidation $import
* @return array
*/
private function rules(WithValidation $import): array
{
return $this->formatKey($import->rules());
}
/**
* @param array $elements
* @return array
*/
private function formatKey(array $elements): array
{
return collect($elements)->mapWithKeys(function ($rule, $attribute) {
$attribute = Str::startsWith($attribute, '*.') ? $attribute : '*.' . $attribute;
return [$attribute => $this->formatRule($rule)];
})->all();
}
/**
* @param string|object|callable|array $rules
* @return string|array
*/
private function formatRule($rules)
{
if (is_array($rules)) {
foreach ($rules as $rule) {
$formatted[] = $this->formatRule($rule);
}
return $formatted ?? [];
}
if (is_object($rules) || is_callable($rules)) {
return $rules;
}
if (Str::contains($rules, 'required_without') && preg_match('/(.*?):(.*)/', $rules, $matches)) {
$column = array_map(function ($match) {
return Str::startsWith($match, '*.') ? $match : '*.' . $match;
}, explode(',', $matches[2]));
return $matches[1] . ':' . implode(',', $column);
}
if (Str::contains($rules, 'required_') && preg_match('/(.*?):(.*),(.*)/', $rules, $matches)) {
$column = Str::startsWith($matches[2], '*.') ? $matches[2] : '*.' . $matches[2];
return $matches[1] . ':' . $column . ',' . $matches[3];
}
return $rules;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Validators/Failure.php | src/Validators/Failure.php | <?php
namespace Maatwebsite\Excel\Validators;
use Illuminate\Contracts\Support\Arrayable;
use JsonSerializable;
class Failure implements Arrayable, JsonSerializable
{
/**
* @var int
*/
protected $row;
/**
* @var string
*/
protected $attribute;
/**
* @var array
*/
protected $errors;
/**
* @var array
*/
private $values;
/**
* @param int $row
* @param string $attribute
* @param array $errors
* @param array $values
*/
public function __construct(int $row, string $attribute, array $errors, array $values = [])
{
$this->row = $row;
$this->attribute = $attribute;
$this->errors = $errors;
$this->values = $values;
}
/**
* @return int
*/
public function row(): int
{
return $this->row;
}
/**
* @return string
*/
public function attribute(): string
{
return $this->attribute;
}
/**
* @return array
*/
public function errors(): array
{
return $this->errors;
}
/**
* @return array
*/
public function values(): array
{
return $this->values;
}
/**
* @return array
*/
public function toArray()
{
return collect($this->errors)->map(function ($message) {
return __('There was an error on row :row. :message', ['row' => $this->row, 'message' => $message]);
})->all();
}
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return [
'row' => $this->row(),
'attribute' => $this->attribute(),
'errors' => $this->errors(),
'values' => $this->values(),
];
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Validators/ValidationException.php | src/Validators/ValidationException.php | <?php
namespace Maatwebsite\Excel\Validators;
use Illuminate\Validation\ValidationException as IlluminateValidationException;
class ValidationException extends IlluminateValidationException
{
/**
* @var Failure[]
*/
protected $failures;
/**
* @param IlluminateValidationException $previous
* @param array $failures
*/
public function __construct(IlluminateValidationException $previous, array $failures)
{
parent::__construct($previous->validator, $previous->response, $previous->errorBag);
$this->failures = $failures;
}
/**
* @return string[]
*/
public function errors(): array
{
return collect($this->failures)->map->toArray()->all();
}
/**
* @return array
*/
public function failures(): array
{
return $this->failures;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Factories/ReaderFactory.php | src/Factories/ReaderFactory.php | <?php
namespace Maatwebsite\Excel\Factories;
use Maatwebsite\Excel\Concerns\MapsCsvSettings;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
use Maatwebsite\Excel\Concerns\WithLimit;
use Maatwebsite\Excel\Concerns\WithReadFilter;
use Maatwebsite\Excel\Concerns\WithStartRow;
use Maatwebsite\Excel\Exceptions\NoTypeDetectedException;
use Maatwebsite\Excel\Files\TemporaryFile;
use Maatwebsite\Excel\Filters\LimitFilter;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Reader\Csv;
use PhpOffice\PhpSpreadsheet\Reader\Exception;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
class ReaderFactory
{
use MapsCsvSettings;
/**
* @param object $import
* @param TemporaryFile $file
* @param string $readerType
* @return IReader
*
* @throws Exception
*/
public static function make($import, TemporaryFile $file, ?string $readerType = null): IReader
{
$reader = IOFactory::createReader(
$readerType ?: static::identify($file)
);
if (method_exists($reader, 'setReadDataOnly')) {
$reader->setReadDataOnly(config('excel.imports.read_only', true));
}
if (method_exists($reader, 'setReadEmptyCells')) {
$reader->setReadEmptyCells(!config('excel.imports.ignore_empty', false));
}
if ($reader instanceof Csv) {
static::applyCsvSettings(config('excel.imports.csv', []));
if ($import instanceof WithCustomCsvSettings) {
static::applyCsvSettings($import->getCsvSettings());
}
$reader->setDelimiter(static::$delimiter);
$reader->setEnclosure(static::$enclosure);
$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) {
$reader->setReadFilter($import->readFilter());
} elseif ($import instanceof WithLimit) {
$reader->setReadFilter(new LimitFilter(
$import instanceof WithStartRow ? $import->startRow() : 1,
$import->limit()
));
}
return $reader;
}
/**
* @param TemporaryFile $temporaryFile
* @return string
*
* @throws NoTypeDetectedException
*/
private static function identify(TemporaryFile $temporaryFile): string
{
try {
return IOFactory::identify($temporaryFile->getLocalPath());
} catch (Exception $e) {
throw new NoTypeDetectedException('', 0, $e);
}
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Factories/WriterFactory.php | src/Factories/WriterFactory.php | <?php
namespace Maatwebsite\Excel\Factories;
use Maatwebsite\Excel\Cache\CacheManager;
use Maatwebsite\Excel\Concerns\MapsCsvSettings;
use Maatwebsite\Excel\Concerns\WithCharts;
use Maatwebsite\Excel\Concerns\WithCustomCsvSettings;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Maatwebsite\Excel\Concerns\WithPreCalculateFormulas;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Csv;
use PhpOffice\PhpSpreadsheet\Writer\Html;
use PhpOffice\PhpSpreadsheet\Writer\IWriter;
class WriterFactory
{
use MapsCsvSettings;
/**
* @param string $writerType
* @param Spreadsheet $spreadsheet
* @param object $export
* @return IWriter
*
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/
public static function make(string $writerType, Spreadsheet $spreadsheet, $export): IWriter
{
$writer = IOFactory::createWriter($spreadsheet, $writerType);
$writer->setUseDiskCaching(
config('excel.cache.driver', CacheManager::DRIVER_MEMORY) !== CacheManager::DRIVER_MEMORY
);
if (static::includesCharts($export)) {
$writer->setIncludeCharts(true);
}
if ($writer instanceof Html && $export instanceof WithMultipleSheets) {
$writer->writeAllSheets();
}
if ($writer instanceof Csv) {
static::applyCsvSettings(config('excel.exports.csv', []));
if ($export instanceof WithCustomCsvSettings) {
static::applyCsvSettings($export->getCsvSettings());
}
$writer->setDelimiter(static::$delimiter);
$writer->setEnclosure(static::$enclosure);
$writer->setEnclosureRequired((bool) static::$enclosure);
$writer->setLineEnding(static::$lineEnding);
$writer->setUseBOM(static::$useBom);
$writer->setIncludeSeparatorLine(static::$includeSeparatorLine);
$writer->setExcelCompatibility(static::$excelCompatibility);
$writer->setOutputEncoding(static::$outputEncoding);
}
// Calculation settings
$writer->setPreCalculateFormulas(
$export instanceof WithPreCalculateFormulas
? true
: config('excel.exports.pre_calculate_formulas', false)
);
return $writer;
}
/**
* @param $export
* @return bool
*/
private static function includesCharts($export): bool
{
if ($export instanceof WithCharts) {
return true;
}
if ($export instanceof WithMultipleSheets) {
foreach ($export->sheets() as $sheet) {
if ($sheet instanceof WithCharts) {
return true;
}
}
}
return false;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Filters/LimitFilter.php | src/Filters/LimitFilter.php | <?php
namespace Maatwebsite\Excel\Filters;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
class LimitFilter implements IReadFilter
{
/**
* @var int
*/
private $startRow;
/**
* @var int
*/
private $endRow;
/**
* @param int $startRow
* @param int $limit
*/
public function __construct(int $startRow, int $limit)
{
$this->startRow = $startRow;
$this->endRow = $startRow + $limit;
}
/**
* @param string $column
* @param int $row
* @param string $worksheetName
* @return bool
*/
public function readCell($column, $row, $worksheetName = '')
{
return $row >= $this->startRow && $row <= $this->endRow;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Filters/ChunkReadFilter.php | src/Filters/ChunkReadFilter.php | <?php
namespace Maatwebsite\Excel\Filters;
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
class ChunkReadFilter implements IReadFilter
{
/**
* @var int
*/
private $headingRow;
/**
* @var int
*/
private $startRow;
/**
* @var int
*/
private $endRow;
/**
* @var string
*/
private $worksheetName;
/**
* @param int $headingRow
* @param int $startRow
* @param int $chunkSize
* @param string $worksheetName
*/
public function __construct(int $headingRow, int $startRow, int $chunkSize, string $worksheetName)
{
$this->headingRow = $headingRow;
$this->startRow = $startRow;
$this->endRow = $startRow + $chunkSize;
$this->worksheetName = $worksheetName;
}
/**
* @param string $column
* @param int $row
* @param string $worksheetName
* @return bool
*/
public function readCell($column, $row, $worksheetName = '')
{
// Only read the heading row, and the rows that are configured in $this->_startRow and $this->_endRow
return ($worksheetName === $this->worksheetName || $worksheetName === '')
&& ($row === $this->headingRow || ($row >= $this->startRow && $row < $this->endRow));
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/AfterChunk.php | src/Events/AfterChunk.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Sheet;
class AfterChunk extends Event
{
/**
* @var Sheet
*/
private $sheet;
/**
* @var int
*/
private $startRow;
public function __construct(Sheet $sheet, $importable, int $startRow)
{
$this->sheet = $sheet;
$this->startRow = $startRow;
parent::__construct($importable);
}
public function getSheet(): Sheet
{
return $this->sheet;
}
public function getDelegate()
{
return $this->sheet;
}
public function getStartRow(): int
{
return $this->startRow;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/BeforeSheet.php | src/Events/BeforeSheet.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Sheet;
class BeforeSheet extends Event
{
/**
* @var Sheet
*/
public $sheet;
/**
* @param Sheet $sheet
* @param object $exportable
*/
public function __construct(Sheet $sheet, $exportable)
{
$this->sheet = $sheet;
parent::__construct($exportable);
}
/**
* @return Sheet
*/
public function getSheet(): Sheet
{
return $this->sheet;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->sheet;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/AfterImport.php | src/Events/AfterImport.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Reader;
class AfterImport extends Event
{
/**
* @var Reader
*/
public $reader;
/**
* @param Reader $reader
* @param object $importable
*/
public function __construct(Reader $reader, $importable)
{
$this->reader = $reader;
parent::__construct($importable);
}
/**
* @return Reader
*/
public function getReader(): Reader
{
return $this->reader;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->reader;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/BeforeWriting.php | src/Events/BeforeWriting.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Writer;
class BeforeWriting extends Event
{
/**
* @var Writer
*/
public $writer;
/**
* @var object
*/
private $exportable;
/**
* @param Writer $writer
* @param object $exportable
*/
public function __construct(Writer $writer, $exportable)
{
$this->writer = $writer;
parent::__construct($exportable);
}
/**
* @return Writer
*/
public function getWriter(): Writer
{
return $this->writer;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->writer;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/Event.php | src/Events/Event.php | <?php
namespace Maatwebsite\Excel\Events;
/**
* @internal
*/
abstract class Event
{
/**
* @var object
*/
protected $concernable;
/**
* @param object $concernable
*/
public function __construct($concernable)
{
$this->concernable = $concernable;
}
/**
* @return object
*/
public function getConcernable()
{
return $this->concernable;
}
/**
* @return mixed
*/
abstract public function getDelegate();
/**
* @param string $concern
* @return bool
*/
public function appliesToConcern(string $concern): bool
{
return $this->getConcernable() instanceof $concern;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/AfterBatch.php | src/Events/AfterBatch.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Imports\ModelManager;
class AfterBatch extends Event
{
/**
* @var ModelManager
*/
public $manager;
/**
* @var int
*/
private $batchSize;
/**
* @var int
*/
private $startRow;
/**
* @param ModelManager $manager
* @param object $importable
* @param int $batchSize
* @param int $startRow
*/
public function __construct(ModelManager $manager, $importable, int $batchSize, int $startRow)
{
$this->manager = $manager;
$this->batchSize = $batchSize;
$this->startRow = $startRow;
parent::__construct($importable);
}
public function getManager(): ModelManager
{
return $this->manager;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->manager;
}
public function getBatchSize(): int
{
return $this->batchSize;
}
public function getStartRow(): int
{
return $this->startRow;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/BeforeExport.php | src/Events/BeforeExport.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Writer;
class BeforeExport extends Event
{
/**
* @var Writer
*/
public $writer;
/**
* @param Writer $writer
* @param object $exportable
*/
public function __construct(Writer $writer, $exportable)
{
$this->writer = $writer;
parent::__construct($exportable);
}
/**
* @return Writer
*/
public function getWriter(): Writer
{
return $this->writer;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->writer;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/ImportFailed.php | src/Events/ImportFailed.php | <?php
namespace Maatwebsite\Excel\Events;
use Throwable;
class ImportFailed
{
/**
* @var Throwable
*/
public $e;
/**
* @param Throwable $e
*/
public function __construct(Throwable $e)
{
$this->e = $e;
}
/**
* @return Throwable
*/
public function getException(): Throwable
{
return $this->e;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/BeforeImport.php | src/Events/BeforeImport.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Reader;
class BeforeImport extends Event
{
/**
* @var Reader
*/
public $reader;
/**
* @param Reader $reader
* @param object $importable
*/
public function __construct(Reader $reader, $importable)
{
$this->reader = $reader;
parent::__construct($importable);
}
/**
* @return Reader
*/
public function getReader(): Reader
{
return $this->reader;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->reader;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/src/Events/AfterSheet.php | src/Events/AfterSheet.php | <?php
namespace Maatwebsite\Excel\Events;
use Maatwebsite\Excel\Sheet;
class AfterSheet extends Event
{
/**
* @var Sheet
*/
public $sheet;
/**
* @param Sheet $sheet
* @param object $exportable
*/
public function __construct(Sheet $sheet, $exportable)
{
$this->sheet = $sheet;
parent::__construct($exportable);
}
/**
* @return Sheet
*/
public function getSheet(): Sheet
{
return $this->sheet;
}
/**
* @return mixed
*/
public function getDelegate()
{
return $this->sheet;
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/tests/ExcelFakeTest.php | tests/ExcelFakeTest.php | <?php
namespace Maatwebsite\Excel\Tests;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Bus\PendingDispatch;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Facades\Excel as ExcelFacade;
use Maatwebsite\Excel\Fakes\ExcelFake;
use Maatwebsite\Excel\Tests\Data\Stubs\ChainedJobStub;
use Maatwebsite\Excel\Tests\Data\Stubs\Database\User;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class ExcelFakeTest extends TestCase
{
public function test_can_fake_an_export()
{
ExcelFacade::fake();
// Excel instance should be swapped to the fake now.
$this->assertInstanceOf(ExcelFake::class, $this->app->make('excel'));
}
public function test_can_assert_against_a_fake_downloaded_export()
{
ExcelFacade::fake();
$response = ExcelFacade::download($this->givenExport(), 'downloaded-filename.csv');
$this->assertInstanceOf(BinaryFileResponse::class, $response);
ExcelFacade::assertDownloaded('downloaded-filename.csv');
ExcelFacade::assertDownloaded('downloaded-filename.csv', function (FromCollection $export) {
return $export->collection()->contains('foo');
});
ExcelFacade::matchByRegex();
ExcelFacade::assertDownloaded('/\w{10}-\w{8}\.csv/');
}
public function test_can_assert_against_a_fake_stored_export()
{
ExcelFacade::fake();
$response = ExcelFacade::store($this->givenExport(), 'stored-filename.csv', 's3');
$this->assertTrue($response);
ExcelFacade::assertStored('stored-filename.csv', 's3');
ExcelFacade::assertStored('stored-filename.csv', 's3', function (FromCollection $export) {
return $export->collection()->contains('foo');
});
ExcelFacade::matchByRegex();
ExcelFacade::assertStored('/\w{6}-\w{8}\.csv/', 's3');
}
public function test_can_assert_regex_against_a_fake_stored_export_with_multiple_files()
{
ExcelFacade::fake();
$response = ExcelFacade::store($this->givenExport(), 'stored-filename-one.csv', 's3');
$this->assertTrue($response);
$response = ExcelFacade::store($this->givenExport(), 'stored-filename-two.csv', 's3');
$this->assertTrue($response);
ExcelFacade::matchByRegex();
ExcelFacade::assertStored('/\w{6}-\w{8}-one\.csv/', 's3');
ExcelFacade::assertStored('/\w{6}-\w{8}-two\.csv/', 's3');
}
public function test_a_callback_can_be_passed_as_the_second_argument_when_asserting_against_a_faked_stored_export()
{
ExcelFacade::fake();
$response = ExcelFacade::store($this->givenExport(), 'stored-filename.csv');
$this->assertTrue($response);
ExcelFacade::assertStored('stored-filename.csv');
ExcelFacade::assertStored('stored-filename.csv', function (FromCollection $export) {
return $export->collection()->contains('foo');
});
ExcelFacade::matchByRegex();
ExcelFacade::assertStored('/\w{6}-\w{8}\.csv/');
}
public function test_can_assert_against_a_fake_queued_export()
{
ExcelFacade::fake();
$response = ExcelFacade::queue($this->givenExport(), 'queued-filename.csv', 's3');
$this->assertInstanceOf(PendingDispatch::class, $response);
ExcelFacade::assertQueued('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3', function (FromCollection $export) {
return $export->collection()->contains('foo');
});
ExcelFacade::matchByRegex();
ExcelFacade::assertQueued('/\w{6}-\w{8}\.csv/', 's3');
}
public function test_can_assert_against_a_fake_implicitly_queued_export()
{
ExcelFacade::fake();
$response = ExcelFacade::store($this->givenQueuedExport(), 'queued-filename.csv', 's3');
$this->assertInstanceOf(PendingDispatch::class, $response);
ExcelFacade::assertStored('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3', function (FromCollection $export) {
return $export->collection()->contains('foo');
});
ExcelFacade::matchByRegex();
ExcelFacade::assertQueued('/\w{6}-\w{8}\.csv/', 's3');
}
public function test_can_assert_against_a_fake_queued_export_with_chain()
{
ExcelFacade::fake();
ExcelFacade::queue(
$this->givenQueuedExport(), 'queued-filename.csv', 's3'
)->chain([
new ChainedJobStub(),
]);
ExcelFacade::assertQueuedWithChain([
new ChainedJobStub(),
]);
}
public function test_can_assert_against_a_fake_raw_export()
{
ExcelFacade::fake();
$response = ExcelFacade::raw($this->givenExport(), \Maatwebsite\Excel\Excel::XLSX);
$this->assertIsString($response);
ExcelFacade::assertExportedInRaw(get_class($this->givenExport()));
ExcelFacade::assertExportedInRaw(get_class($this->givenExport()), function (FromCollection $export) {
return $export->collection()->contains('foo');
});
}
public function test_can_assert_against_a_fake_import()
{
ExcelFacade::fake();
ExcelFacade::import($this->givenImport(), 'stored-filename.csv', 's3');
ExcelFacade::assertImported('stored-filename.csv', 's3');
ExcelFacade::assertImported('stored-filename.csv', 's3', function (ToModel $import) {
return $import->model([]) instanceof User;
});
ExcelFacade::matchByRegex();
ExcelFacade::assertImported('/\w{6}-\w{8}\.csv/', 's3');
}
public function test_can_assert_against_a_fake_import_with_uploaded_file()
{
ExcelFacade::fake();
ExcelFacade::import($this->givenImport(), $this->givenUploadedFile(__DIR__ . '/Data/Disks/Local/import.xlsx'));
ExcelFacade::assertImported('import.xlsx');
ExcelFacade::assertImported('import.xlsx', function (ToModel $import) {
return $import->model([]) instanceof User;
});
ExcelFacade::matchByRegex();
ExcelFacade::assertImported('/\w{6}\.xlsx/');
}
public function test_can_assert_against_a_fake_queued_import()
{
ExcelFacade::fake();
$response = ExcelFacade::queueImport($this->givenQueuedImport(), 'queued-filename.csv', 's3');
$this->assertInstanceOf(PendingDispatch::class, $response);
ExcelFacade::assertImported('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3', function (ToModel $import) {
return $import->model([]) instanceof User;
});
ExcelFacade::matchByRegex();
ExcelFacade::assertQueued('/\w{6}-\w{8}\.csv/', 's3');
}
public function test_can_assert_against_a_fake_implicitly_queued_import()
{
ExcelFacade::fake();
$response = ExcelFacade::import($this->givenQueuedImport(), 'queued-filename.csv', 's3');
$this->assertInstanceOf(PendingDispatch::class, $response);
ExcelFacade::assertImported('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3');
ExcelFacade::assertQueued('queued-filename.csv', 's3', function (ToModel $import) {
return $import->model([]) instanceof User;
});
ExcelFacade::matchByRegex();
ExcelFacade::assertQueued('/\w{6}-\w{8}\.csv/', 's3');
}
public function test_can_assert_against_a_fake_queued_import_with_chain()
{
ExcelFacade::fake();
ExcelFacade::queueImport(
$this->givenQueuedImport(), 'queued-filename.csv', 's3'
)->chain([
new ChainedJobStub(),
]);
ExcelFacade::assertQueuedWithChain([
new ChainedJobStub(),
]);
}
public function test_a_callback_can_be_passed_as_the_second_argument_when_asserting_against_a_faked_queued_export()
{
ExcelFacade::fake();
$response = ExcelFacade::queue($this->givenExport(), 'queued-filename.csv');
$this->assertInstanceOf(PendingDispatch::class, $response);
ExcelFacade::assertQueued('queued-filename.csv');
ExcelFacade::assertQueued('queued-filename.csv', function (FromCollection $export) {
return $export->collection()->contains('foo');
});
ExcelFacade::matchByRegex();
ExcelFacade::assertQueued('/\w{6}-\w{8}\.csv/');
}
/**
* @return FromCollection
*/
private function givenExport()
{
return new class implements FromCollection
{
/**
* @return Collection
*/
public function collection()
{
return collect(['foo', 'bar']);
}
};
}
/**
* @return FromCollection
*/
private function givenQueuedExport()
{
return new class implements FromCollection, ShouldQueue
{
/**
* @return Collection
*/
public function collection()
{
return collect(['foo', 'bar']);
}
};
}
/**
* @return object
*/
private function givenImport()
{
return new class implements ToModel
{
/**
* @param array $row
* @return Model|null
*/
public function model(array $row)
{
return new User([]);
}
};
}
/**
* @return object
*/
private function givenQueuedImport()
{
return new class implements ToModel, ShouldQueue
{
/**
* @param array $row
* @return Model|null
*/
public function model(array $row)
{
return new User([]);
}
};
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/tests/HeadingRowImportTest.php | tests/HeadingRowImportTest.php | <?php
namespace Maatwebsite\Excel\Tests;
use Maatwebsite\Excel\HeadingRowImport;
use Maatwebsite\Excel\Imports\HeadingRowFormatter;
class HeadingRowImportTest extends TestCase
{
protected function tearDown(): void
{
HeadingRowFormatter::reset();
parent::tearDown();
}
public function test_can_import_only_heading_row()
{
$import = new HeadingRowImport();
$headings = $import->toArray('import-users-with-headings.xlsx');
$this->assertEquals([
[
['name', 'email'],
],
], $headings);
}
public function test_can_import_only_heading_row_with_custom_heading_row_formatter()
{
HeadingRowFormatter::extend('custom', function ($value) {
return 'custom-' . $value;
});
HeadingRowFormatter::default('custom');
$import = new HeadingRowImport();
$headings = $import->toArray('import-users-with-headings.xlsx');
$this->assertEquals([
[
['custom-name', 'custom-email'],
],
], $headings);
}
public function test_can_import_only_heading_row_with_custom_heading_row_formatter_with_key()
{
HeadingRowFormatter::extend('custom', function ($value, $key) {
return $key;
});
HeadingRowFormatter::default('custom');
$import = new HeadingRowImport();
$headings = $import->toArray('import-users-with-headings.xlsx');
$this->assertEquals([
[
[0, 1],
],
], $headings);
}
public function test_can_import_only_heading_row_with_custom_row_number()
{
$import = new HeadingRowImport(2);
$headings = $import->toArray('import-users-with-headings.xlsx');
$this->assertEquals([
[
['patrick_brouwers', 'patrick_at_maatwebsitenl'],
],
], $headings);
}
public function test_can_import_only_heading_row_for_multiple_sheets()
{
$import = new HeadingRowImport();
$headings = $import->toArray('import-multiple-sheets.xlsx');
$this->assertEquals([
[
['1a1', '1b1'], // slugged first row of sheet 1
],
[
['2a1', '2b1'], // slugged first row of sheet 2
],
], $headings);
}
public function test_can_import_only_heading_row_for_multiple_sheets_with_key()
{
HeadingRowFormatter::extend('custom', function ($value, $key) {
return $key;
});
HeadingRowFormatter::default('custom');
$import = new HeadingRowImport();
$headings = $import->toArray('import-multiple-sheets.xlsx');
$this->assertEquals([
[
[0, 1], // slugged first row of sheet 1
],
[
[0, 1], // slugged first row of sheet 2
],
], $headings);
}
public function test_can_import_only_heading_row_for_multiple_sheets_with_custom_row_number()
{
$import = new HeadingRowImport(2);
$headings = $import->toArray('import-multiple-sheets.xlsx');
$this->assertEquals([
[
['1a2', '1b2'], // slugged 2nd row of sheet 1
],
[
['2a2', '2b2'], // slugged 2nd row of sheet 2
],
], $headings);
}
public function test_can_import_heading_row_with_custom_formatter_defined_in_config()
{
HeadingRowFormatter::extend('custom2', function ($value) {
return 'custom2-' . $value;
});
config()->set('excel.imports.heading_row.formatter', 'custom2');
$import = new HeadingRowImport();
$headings = $import->toArray('import-users-with-headings.xlsx');
$this->assertEquals([
[
['custom2-name', 'custom2-email'],
],
], $headings);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/tests/TestCase.php | tests/TestCase.php | <?php
namespace Maatwebsite\Excel\Tests;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Http\Testing\File;
use Maatwebsite\Excel\ExcelServiceProvider;
use Orchestra\Testbench\TestCase as OrchestraTestCase;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PHPUnit\Framework\Constraint\StringContains;
class TestCase extends OrchestraTestCase
{
/**
* @param string $filePath
* @param string $writerType
* @return \PhpOffice\PhpSpreadsheet\Spreadsheet
*
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function read(string $filePath, string $writerType)
{
$reader = IOFactory::createReader($writerType);
return $reader->load($filePath);
}
/**
* @param string $filePath
* @param string|null $filename
* @return File
*/
public function givenUploadedFile(string $filePath, ?string $filename = null): File
{
$filename = $filename ?? basename($filePath);
// Create temporary file.
$newFilePath = tempnam(sys_get_temp_dir(), 'import-');
// Copy the existing file to a temporary file.
copy($filePath, $newFilePath);
return new File($filename, fopen($newFilePath, 'r'));
}
/**
* @param string $filePath
* @param string $writerType
* @param int|null $sheetIndex
* @return array
*
* @throws \PhpOffice\PhpSpreadsheet\Exception
*/
protected function readAsArray(string $filePath, string $writerType, ?int $sheetIndex = null)
{
$spreadsheet = $this->read($filePath, $writerType);
if (null === $sheetIndex) {
$sheet = $spreadsheet->getActiveSheet();
} else {
$sheet = $spreadsheet->getSheet($sheetIndex);
}
return $sheet->toArray();
}
/**
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app)
{
return [
ExcelServiceProvider::class,
];
}
/**
* @param \Illuminate\Foundation\Application $app
*/
protected function getEnvironmentSetUp($app)
{
$app['config']->set('filesystems.disks.local.root', __DIR__ . '/Data/Disks/Local');
$app['config']->set('filesystems.disks.test', [
'driver' => 'local',
'root' => __DIR__ . '/Data/Disks/Test',
]);
$app['config']->set('database.default', 'testing');
$app['config']->set('database.connections.testing', [
'driver' => 'mysql',
'host' => env('DB_HOST'),
'port' => env('DB_PORT'),
'database' => env('DB_DATABASE'),
'username' => env('DB_USERNAME'),
'password' => env('DB_PASSWORD'),
]);
$app['config']->set('view.paths', [
__DIR__ . '/Data/Stubs/Views',
]);
}
/**
* @param Job $job
* @param string $property
* @return mixed
*/
protected function inspectJobProperty(Job $job, string $property)
{
$dict = (array) unserialize($job->payload()['data']['command']);
$class = $job->resolveName();
return $dict[$property] ?? $dict["\0*\0$property"] ?? $dict["\0$class\0$property"];
}
/**
* @param string $needle
* @param string $haystack
* @param string $message
*/
protected function assertStringContains(string $needle, string $haystack, string $message = '')
{
if (method_exists($this, 'assertStringContainsString')) {
$this->assertStringContainsString($needle, $haystack, $message);
} else {
static::assertThat($haystack, new StringContains($needle, false), $message);
}
}
/**
* @param string $path
*/
protected function assertFileMissing(string $path)
{
if (method_exists($this, 'assertFileDoesNotExist')) {
$this->assertFileDoesNotExist($path);
} else {
$this->assertFileNotExists($path);
}
}
protected function assertRegex(string $pattern, string $string)
{
if (method_exists($this, 'assertMatchesRegularExpression')) {
$this->assertMatchesRegularExpression($pattern, $string);
} else {
$this->assertRegExp($pattern, $string);
}
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/tests/DelegatedMacroableTest.php | tests/DelegatedMacroableTest.php | <?php
namespace Maatwebsite\Excel\Tests;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\RegistersEventListeners;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\BeforeExport;
use Maatwebsite\Excel\Events\BeforeSheet;
use Maatwebsite\Excel\Sheet;
use Maatwebsite\Excel\Writer;
use PhpOffice\PhpSpreadsheet\Document\Properties;
class DelegatedMacroableTest extends TestCase
{
public function test_can_call_methods_from_delegate()
{
$export = new class implements WithEvents
{
use RegistersEventListeners, Exportable;
public static function beforeExport(BeforeExport $event)
{
// ->getProperties() will be called via __call on the ->getDelegate()
TestCase::assertInstanceOf(Properties::class, $event->writer->getProperties());
}
};
$export->download('some-file.xlsx');
}
public function test_can_use_writer_macros()
{
$called = false;
Writer::macro('test', function () use (&$called) {
$called = true;
});
$export = new class implements WithEvents
{
use RegistersEventListeners, Exportable;
public static function beforeExport(BeforeExport $event)
{
// call macro method
$event->writer->test();
}
};
$export->download('some-file.xlsx');
$this->assertTrue($called);
}
public function test_can_use_sheet_macros()
{
$called = false;
Sheet::macro('test', function () use (&$called) {
$called = true;
});
$export = new class implements WithEvents
{
use RegistersEventListeners, Exportable;
public static function beforeSheet(BeforeSheet $event)
{
// call macro method
$event->sheet->test();
}
};
$export->download('some-file.xlsx');
$this->assertTrue($called);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/tests/QueuedViewExportTest.php | tests/QueuedViewExportTest.php | <?php
namespace Maatwebsite\Excel\Tests;
use Illuminate\Support\Collection;
use Maatwebsite\Excel\Tests\Data\Stubs\AfterQueueExportJob;
use Maatwebsite\Excel\Tests\Data\Stubs\Database\User;
use Maatwebsite\Excel\Tests\Data\Stubs\FromViewExportWithMultipleSheets;
use Maatwebsite\Excel\Tests\Data\Stubs\SheetForUsersFromView;
class QueuedViewExportTest extends TestCase
{
/**
* Setup the test environment.
*/
protected function setUp(): void
{
parent::setUp();
$this->loadLaravelMigrations(['--database' => 'testing']);
$this->withFactories(__DIR__ . '/Data/Stubs/Database/Factories');
}
public function test_can_queue_an_export()
{
$users = factory(User::class)->times(100)->create([]);
$export = new SheetForUsersFromView($users);
$export->queue('queued-view-export.xlsx')->chain([
new AfterQueueExportJob(__DIR__ . '/Data/Disks/Local/queued-view-export.xlsx'),
]);
$actual = $this->readAsArray(__DIR__ . '/Data/Disks/Local/queued-view-export.xlsx', 'Xlsx');
$this->assertCount(101, $actual);
}
public function test_can_export_multiple_sheets_from_view()
{
/** @var Collection|User[] $users */
$users = factory(User::class)->times(300)->make();
$export = new FromViewExportWithMultipleSheets($users);
$export->queue('queued-multiple-view-export.xlsx')->chain([
new AfterQueueExportJob(__DIR__ . '/Data/Disks/Local/queued-multiple-view-export.xlsx'),
]);
$contents = $this->readAsArray(__DIR__ . '/Data/Disks/Local/queued-multiple-view-export.xlsx', 'Xlsx', 0);
$expected = $users->forPage(1, 100)->map(function (User $user) {
return [
$user->name,
$user->email,
];
})->prepend(['Name', 'Email'])->toArray();
$this->assertEquals(101, sizeof($contents));
$this->assertEquals($expected, $contents);
$contents = $this->readAsArray(__DIR__ . '/Data/Disks/Local/queued-multiple-view-export.xlsx', 'Xlsx', 2);
$expected = $users->forPage(3, 100)->map(function (User $user) {
return [
$user->name,
$user->email,
];
})->prepend(['Name', 'Email'])->toArray();
$this->assertEquals(101, sizeof($contents));
$this->assertEquals($expected, $contents);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
SpartnerNL/Laravel-Excel | https://github.com/SpartnerNL/Laravel-Excel/blob/b31b6f4eabd8b5ff3f873e808abd183d3f5cb244/tests/CellTest.php | tests/CellTest.php | <?php
namespace Maatwebsite\Excel\Tests;
use Maatwebsite\Excel\Cell;
use Maatwebsite\Excel\Middleware\ConvertEmptyCellValuesToNull;
use Maatwebsite\Excel\Middleware\TrimCellValue;
class CellTest extends TestCase
{
public function test_can_get_cell_value()
{
config()->set('excel.imports.cells.middleware', []);
$worksheet = $this->read(__DIR__ . '/Data/Disks/Local/import-middleware.xlsx', 'Xlsx');
$this->assertEquals('test', Cell::make($worksheet->getActiveSheet(), 'A1')->getValue());
// By default spaces are not removed
$this->assertEquals(' ', Cell::make($worksheet->getActiveSheet(), 'A2')->getValue());
}
public function test_can_trim_empty_cells()
{
config()->set('excel.imports.cells.middleware', [
TrimCellValue::class,
]);
$worksheet = $this->read(__DIR__ . '/Data/Disks/Local/import-middleware.xlsx', 'Xlsx');
$this->assertEquals('', Cell::make($worksheet->getActiveSheet(), 'A2')->getValue());
config()->set('excel.imports.cells.middleware', []);
}
public function test_convert_empty_cells_to_null()
{
config()->set('excel.imports.cells.middleware', [
TrimCellValue::class,
ConvertEmptyCellValuesToNull::class,
]);
$worksheet = $this->read(__DIR__ . '/Data/Disks/Local/import-middleware.xlsx', 'Xlsx');
$this->assertEquals(null, Cell::make($worksheet->getActiveSheet(), 'A2')->getValue());
config()->set('excel.imports.cells.middleware', []);
}
}
| php | MIT | b31b6f4eabd8b5ff3f873e808abd183d3f5cb244 | 2026-01-04T15:03:06.866936Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.