Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 11 #10972

Merged
merged 42 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2af4b60
init: Laravel 11
danharrin Jan 21, 2024
38ea608
Update composer.lock
danharrin Jan 21, 2024
7fb5bd4
wip
danharrin Jan 21, 2024
033e601
Update composer.lock
danharrin Jan 21, 2024
494d041
exc php 8.1
danharrin Jan 21, 2024
592eaa6
update docs
hafezdivandari Feb 15, 2024
bd6cdf6
update dependencies
hafezdivandari Feb 15, 2024
23e37a4
remove doctrine dbal
hafezdivandari Feb 15, 2024
5040970
wip
hafezdivandari Feb 15, 2024
4295f0d
parse default expressions
hafezdivandari Feb 16, 2024
08377d1
Merge branch '3.x' into laravel-11
danharrin Feb 21, 2024
89e8626
SP registration
danharrin Feb 21, 2024
b9e183f
Merge remote-tracking branch 'upstream/laravel-11' into laravel-11-re…
hafezdivandari Feb 21, 2024
bc009a2
update
danharrin Feb 21, 2024
1e42712
Update .stubs.php
danharrin Feb 23, 2024
498dbf5
Bump min Laravel version
danharrin Feb 23, 2024
c2a7549
Merge branch '3.x' into laravel-11
danharrin Feb 23, 2024
9b5fe62
Update composer.json
danharrin Feb 23, 2024
ff53aca
Merge branch '3.x' into pr/11429
danharrin Feb 23, 2024
192aacb
Update composer.json
danharrin Feb 23, 2024
4ade843
Merge branch 'laravel-11' into pr/11429
danharrin Feb 23, 2024
d857d90
Update composer.json
danharrin Feb 23, 2024
da45437
Merge branch '3.x' into laravel-11
danharrin Feb 23, 2024
c01a3e2
Merge branch 'laravel-11' into pr/11429
danharrin Feb 23, 2024
e4040a6
wip
danharrin Feb 23, 2024
cd2403d
Merge pull request #11429 from hafezdivandari/laravel-11-remove-doctr…
danharrin Feb 23, 2024
80020a5
chore: fix code style
danharrin Feb 23, 2024
8992495
Merge branch '3.x' into laravel-11
danharrin Feb 23, 2024
4422ae5
Merge branch '3.x' into laravel-11
danharrin Feb 23, 2024
9d3c97d
Merge branch '3.x' into laravel-11
danharrin Feb 23, 2024
f026dee
Merge branch '3.x' into laravel-11
danharrin Feb 24, 2024
410655a
Merge branch '3.x' into laravel-11
danharrin Feb 24, 2024
fab2099
Merge branch '3.x' into laravel-11
danharrin Feb 25, 2024
9793ac2
Update
danharrin Feb 25, 2024
71ba5c4
remove rector tests
danharrin Feb 25, 2024
7bd86ed
Update composer.lock
danharrin Feb 26, 2024
359ebb0
update
danharrin Feb 26, 2024
060dd04
Update RectorTest.php
danharrin Feb 26, 2024
fec7553
Use Testbench configuration feature
crynobone Feb 27, 2024
aa84460
wip
crynobone Feb 27, 2024
493d560
wip
crynobone Feb 27, 2024
5fc7fbe
Merge pull request #11595 from crynobone/laravel-11
danharrin Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -14,17 +14,12 @@ protected function getExporterColumns(string $model): string
return '//';
}

$schema = $this->getModelSchema($model);
$table = $this->getModelTable($model);

if (blank($table)) {
return '//';
}

$columns = [];

foreach ($table->getColumns() as $column) {
$columnName = $column->getName();

foreach ($schema->getColumnListing($table) as $columnName) {
if (str($columnName)->endsWith([
'_token',
])) {
@@ -38,10 +33,10 @@ protected function getExporterColumns(string $model): string
}

if (str($columnName)->endsWith('_id')) {
$guessedRelationshipName = $this->guessBelongsToRelationshipName($column, $model);
$guessedRelationshipName = $this->guessBelongsToRelationshipName($columnName, $model);

if (filled($guessedRelationshipName)) {
$guessedRelationshipTitleColumnName = $this->guessBelongsToRelationshipTitleColumnName($column, app($model)->{$guessedRelationshipName}()->getModel()::class);
$guessedRelationshipTitleColumnName = $this->guessBelongsToRelationshipTitleColumnName($columnName, app($model)->{$guessedRelationshipName}()->getModel()::class);

$columnName = "{$guessedRelationshipName}.{$guessedRelationshipTitleColumnName}";
}
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

namespace Filament\Actions\Commands\Concerns;

use Doctrine\DBAL\Types;
use Illuminate\Support\Str;

trait CanGenerateImporterColumns
@@ -15,20 +14,17 @@ protected function getImporterColumns(string $model): string
return '//';
}

$schema = $this->getModelSchema($model);
$table = $this->getModelTable($model);

if (blank($table)) {
return '//';
}

$columns = [];

foreach ($table->getColumns() as $column) {
if ($column->getAutoincrement()) {
foreach ($schema->getColumns($table) as $column) {
if ($column['auto_increment']) {
continue;
}

$columnName = $column->getName();
$columnName = $column['name'];

if (str($columnName)->is([
app($model)->getKeyName(),
@@ -50,7 +46,7 @@ protected function getImporterColumns(string $model): string
$columnData['label'] = [Str::upper($columnName)];
}

if ($column->getNotnull()) {
if (! $column['nullable']) {
$columnData['rules'][0][] = 'required';
$columnData['requiredMapping'] = [];
}
@@ -59,44 +55,39 @@ protected function getImporterColumns(string $model): string
$columnData['rules'][0][] = 'email';
}

$type = $this->parseColumnType($column);

if (
str($columnName)->endsWith('_id') &&
filled($guessedRelationshipName = $this->guessBelongsToRelationshipName($column, $model))
filled($guessedRelationshipName = $this->guessBelongsToRelationshipName($columnName, $model))
) {
$columnName = $guessedRelationshipName;
$columnData['relationship'] = [];
} elseif (in_array($column->getType()::class, [
Types\BooleanType::class,
} elseif (in_array($type['name'], [
'boolean',
])) {
$columnData['rules'][0][] = 'boolean';
$columnData['boolean'] = [];
} elseif (in_array($column->getType()::class, [
Types\DateImmutableType::class,
Types\DateType::class,
} elseif (in_array($type['name'], [
'date',
])) {
$columnData['rules'][0][] = 'date';
} elseif (in_array($column->getType()::class, [
Types\DateTimeImmutableType::class,
Types\DateTimeType::class,
Types\DateTimeTzImmutableType::class,
Types\DateTimeTzType::class,
} elseif (in_array($type['name'], [
'datetime',
'timestamp',
])) {
$columnData['rules'][0][] = 'datetime';
} elseif (in_array($column->getType()::class, [
Types\IntegerType::class,
Types\SmallIntType::class,
Types\BigIntType::class,
])) {
$columnData['rules'][0][] = 'integer';
$columnData['numeric'] = [];
} elseif (in_array($column->getType()::class, [
Types\DecimalType::class,
Types\FloatType::class,
} elseif (in_array($type['name'], [
'integer',
'decimal',
'float',
'double',
'money',
])) {
$columnData['rules'][0][] = 'integer';
$columnData['numeric'] = [];
} elseif ($length = $column->getLength()) {
$columnData['rules'][0][] = "max:{$length}";
} elseif (isset($type['length'])) {
$columnData['rules'][0][] = "max:{$type['length']}";
}

// Move rules to the end of the column definition.
54 changes: 26 additions & 28 deletions packages/forms/src/Commands/Concerns/CanGenerateForms.php
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

namespace Filament\Forms\Commands\Concerns;

use Doctrine\DBAL\Types;
use Filament\Forms;
use Illuminate\Support\Str;

@@ -16,20 +15,17 @@ protected function getResourceFormSchema(string $model): string
return '//';
}

$schema = $this->getModelSchema($model);
$table = $this->getModelTable($model);

if (blank($table)) {
return '//';
}

$components = [];

foreach ($table->getColumns() as $column) {
if ($column->getAutoincrement()) {
foreach ($schema->getColumns($table) as $column) {
if ($column['auto_increment']) {
continue;
}

$columnName = $column->getName();
$columnName = $column['name'];

if (str($columnName)->is([
app($model)->getKeyName(),
@@ -41,22 +37,24 @@ protected function getResourceFormSchema(string $model): string
continue;
}

$type = $this->parseColumnType($column);

$componentData = [];

$componentData['type'] = match (true) {
$column->getType()::class === Types\BooleanType::class => Forms\Components\Toggle::class,
in_array($column->getType()::class, [Types\DateImmutableType::class, Types\DateType::class]) => Forms\Components\DatePicker::class,
in_array($column->getType()::class, [Types\DateTimeImmutableType::class, Types\DateTimeType::class, Types\DateTimeTzImmutableType::class, Types\DateTimeTzType::class]) => Forms\Components\DateTimePicker::class,
$column->getType()::class === Types\TextType::class => Forms\Components\Textarea::class,
$type['name'] === 'boolean' => Forms\Components\Toggle::class,
$type['name'] === 'date' => Forms\Components\DatePicker::class,
in_array($type['name'], ['datetime', 'timestamp']) => Forms\Components\DateTimePicker::class,
$type['name'] === 'text' => Forms\Components\Textarea::class,
$columnName === 'image', str($columnName)->startsWith('image_'), str($columnName)->contains('_image_'), str($columnName)->endsWith('_image') => Forms\Components\FileUpload::class,
default => Forms\Components\TextInput::class,
};

if (str($columnName)->endsWith('_id')) {
$guessedRelationshipName = $this->guessBelongsToRelationshipName($column, $model);
$guessedRelationshipName = $this->guessBelongsToRelationshipName($columnName, $model);

if (filled($guessedRelationshipName)) {
$guessedRelationshipTitleColumnName = $this->guessBelongsToRelationshipTitleColumnName($column, app($model)->{$guessedRelationshipName}()->getModel()::class);
$guessedRelationshipTitleColumnName = $this->guessBelongsToRelationshipTitleColumnName($columnName, app($model)->{$guessedRelationshipName}()->getModel()::class);

$componentData['type'] = Forms\Components\Select::class;
$componentData['relationship'] = [$guessedRelationshipName, $guessedRelationshipTitleColumnName];
@@ -89,40 +87,40 @@ protected function getResourceFormSchema(string $model): string
$componentData['image'] = [];
}

if ($column->getNotnull()) {
if (! $column['nullable']) {
$componentData['required'] = [];
}

if (in_array($column->getType()::class, [
Types\BigIntType::class,
Types\DecimalType::class,
Types\FloatType::class,
Types\IntegerType::class,
Types\SmallIntType::class,
if (in_array($type['name'], [
'integer',
'decimal',
'float',
'double',
'money',
])) {
if ($componentData['type'] === Forms\Components\TextInput::class) {
$componentData['numeric'] = [];
}

if (filled($column->getDefault())) {
$componentData['default'] = [$column->getDefault()];
if (filled($column['default'])) {
$componentData['default'] = [$column['default']];
}

if (in_array($columnName, [
'cost',
'money',
'price',
])) {
]) || $type['name'] === 'money') {
$componentData['prefix'] = ['$'];
}
} elseif (in_array($componentData['type'], [
Forms\Components\TextInput::class,
Forms\Components\Textarea::class,
]) && ($length = $column->getLength())) {
$componentData['maxLength'] = [$length];
]) && isset($type['length'])) {
$componentData['maxLength'] = [$type['length']];

if (filled($column->getDefault())) {
$componentData['default'] = [$column->getDefault()];
if (filled($column['default'])) {
$componentData['default'] = [$column['default']];
}
}

Loading