The
collect
function creates a collection instance from the given value:<?php $collection = collect(['taylor', 'abigail']);
<?php protected function shouldGenerate(array $types, array $only, array $skip): bool
{
if (count($only)) {
return collect($types)->intersect($only)->isNotEmpty();
}
if (count($skip)) {
<?php }
if (count($skip)) {
return collect($types)->intersect($skip)->isEmpty();
}
return true;
<?php $blueprint = resolve(Blueprint::class);
$generated = $this->builder->execute($blueprint, $this->filesystem, $file, $only, $skip, $overwriteMigrations);
collect($generated)->each(
function ($files, $action) {
$this->line(Str::studly($action) . ':', $this->outputStyle($action));
collect($files)->each(
<?php collect($generated)->each(
function ($files, $action) {
$this->line(Str::studly($action) . ':', $this->outputStyle($action));
collect($files)->each(
function ($file) {
$this->line('- ' . $file);
}
<?php $generated = $blueprint->parse($contents, false);
collect($generated)->each(
function ($files, $action) {
if ($action === 'created') {
$this->line('Deleted:', $this->outputStyle($action));
<?php return;
}
collect($files)->each(
function ($file) {
$this->line('- ' . $file);
}
<?php protected function buildImports(Model $model)
{
return collect($this->imports[$model->name()])
->map(fn ($class) => "use {$class};")
->unique()
->sort()
<?php return '';
}
$traits = collect($this->traits[$model->name()])
->unique()
->sort()
->implode(', ');
<?php protected function createMigrations(array $tables, $overwrite = false): array
{
$sequential_timestamp = \Carbon\Carbon::now()->copy()->subSeconds(
collect($tables['tableNames'])->merge($tables['pivotTableNames'])->merge($tables['polymorphicManyToManyTables'])->count()
);
foreach ($tables['tableNames'] as $tableName => $data) {
<?php }
$modifiers = collect($modifiers)->reject(
fn ($modifier) => (is_array($modifier) && key($modifier) === 'foreign')
|| (is_array($modifier) && key($modifier) === 'onDelete')
|| (is_array($modifier) && key($modifier) === 'onUpdate')
<?php }
$on_delete_suffix = $on_update_suffix = null;
$on_delete_clause = collect($modifiers)->firstWhere('onDelete');
if (config('blueprint.use_constraints') || $on_delete_clause) {
$on_delete_clause = $on_delete_clause ? $on_delete_clause['onDelete'] : config('blueprint.on_delete', 'cascade');
$on_delete_suffix = self::ON_DELETE_CLAUSES[$on_delete_clause];
<?php $on_delete_suffix = self::ON_DELETE_CLAUSES[$on_delete_clause];
}
$on_update_clause = collect($modifiers)->firstWhere('onUpdate');
if (config('blueprint.use_constraints') || $on_update_clause) {
$on_update_clause = $on_update_clause ? $on_update_clause['onUpdate'] : config('blueprint.on_update', 'cascade');
$on_update_suffix = self::ON_UPDATE_CLAUSES[$on_update_clause];
<?php $name = '_create_' . $tableName . '_table.php';
if ($overwrite) {
$migrations = collect($this->filesystem->files($dir))
->filter(
fn (SplFileInfo $file) => str_contains($file->getFilename(), $name)
)
<?php protected function getPivotTableName(array $segments)
{
$isCustom = collect($segments)
->filter(
fn ($segment) => Str::contains($segment, ':')
)->first();
<?php $type = Str::after($type, 'unsigned');
}
return collect(self::UNSIGNABLE_TYPES)
->contains(
fn ($value) => strtolower($value) === strtolower($type)
);