Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Strip whitespace (or other characters) from the beginning and end of a string
<?php trim(string $string, string $characters = " \n\r\t\v\x00"): string
<?php return array_map(
function ($option) {
$raw_value = str_replace("''", "'", trim($option, "'"));
if (!preg_match('/\s/', $raw_value)) {
return $raw_value;
<?php }
if (!empty($body)) {
$method = str_replace('{{ body }}', trim($body), $method);
}
if (Blueprint::useReturnTypeHints()) {
<?php $methods .= PHP_EOL . $method;
}
return trim($methods);
}
private function determineModel(Controller $controller, ?string $reference)
<?php return '//';
}
return trim($definition);
}
private function fillableColumns(array $columns): array
<?php $definition .= self::INDENT . '$table->' . $model->timestampsDataType() . '();' . PHP_EOL;
}
return trim($definition);
}
protected function buildPivotTableDefinition(array $segments)
<?php }
}
return trim($definition);
}
protected function buildPolyTableDefinition(string $parentTable)
<?php $definition .= self::INDENT . sprintf('$table->unsignedBigInteger(\'%s\');', Str::lower(Str::singular($parentTable) . 'able' . '_id')) . PHP_EOL;
$definition .= self::INDENT . sprintf('$table->string(\'%s\');', Str::lower(Str::singular($parentTable) . 'able' . '_type')) . PHP_EOL;
return trim($definition);
}
protected function buildForeignKey(string $column_name, ?string $on, string $type, array $attributes = [], array $modifiers = [])
<?php $body .= PHP_EOL . PHP_EOL;
$body .= $this->buildRelationships($model);
$stub = str_replace('use HasFactory;', 'use HasFactory;' . PHP_EOL . PHP_EOL . ' ' . trim($body), $stub);
$stub = $this->addTraits($model, $stub);
<?php $properties .= PHP_EOL . str_replace('[]', $this->pretty_print_array($columns), $this->filesystem->stub('model.casts.stub'));
}
return trim($properties);
}
protected function buildRelationships(Model $model)
<?php $output = preg_replace('/^(\s+)[^=]+=>\s+/m', '$1', $output);
}
return trim(str_replace("\n", PHP_EOL, $output));
}
private function phpDataType(string $dataType)
<?php $routes .= ';' . PHP_EOL;
}
return trim($routes);
}
protected function getClassName(Controller $controller)
<?php $stub = str_replace('{{ body }}', $this->buildAssignments($statement->data()), $stub);
}
return trim($stub);
}
protected function buildProperties(array $data)
<?php protected function buildProperties(array $data)
{
return trim(
array_reduce(
$data,
function ($output, $property) {
$output .= ' public $' . $property . ';' . PHP_EOL . PHP_EOL;
return $output;
},
''
)
);
}
protected function buildAssignments(array $data)
<?php protected function buildAssignments(array $data)
{
return trim(
array_reduce(
$data,
function ($output, $property) {
$output .= ' $this->' . $property . ' = $' . $property . ';' . PHP_EOL;
return $output;
},
''
)
);
}
protected function buildParameters(array $data)
<?php protected function buildRules(string $context, ValidateStatement $validateStatement)
{
return trim(
array_reduce(
$validateStatement->data(),
function ($output, $field) use ($context) {
[$qualifier, $column] = $this->splitField($field);
if (is_null($qualifier)) {
$qualifier = $context;
}
$validationRules = $this->validationRules($qualifier, $column);
foreach ($validationRules as $name => $rule) {
$formattedRule = implode("', '", $rule);
$output .= self::INDENT . "'{$name}' => ['{$formattedRule}']," . PHP_EOL;
}
return $output;
},
''
)
);
}
private function getName(string $context, string $method)