-
Notifications
You must be signed in to change notification settings - Fork 1
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
THE001-90 handle exception for foreign key constraints #42
base: master
Are you sure you want to change the base?
Conversation
…te-record' into feature/THE001-90-errors-on-delete-record
…te-record' into feature/THE001-90-errors-on-delete-record
$resourceClass = get_class($model); | ||
|
||
$filamentResource = collect(Filament::getResources()) | ||
->first(function ($filamentResource) use ($resourceClass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kan je hier geen arrow function gebruiken? fn () => ...
- typing voorzien, is
$filamentResource
een string, array, Model?
return $filamentResource::getModel() === $resourceClass; | ||
}); | ||
|
||
if (! $filamentResource) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waarom die if
als je toch gewoon $filamentResource
returned daaronder?
@@ -28,3 +30,38 @@ function is_image_with_dimensions(string $extension): bool | |||
return in_array($extension, config('filament-media-library.extensions.image', [])) && $extension !== 'svg'; | |||
} | |||
} | |||
|
|||
if (! function_exists('get_resource_by_model')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filament heeft hier zelf een functie voor: https://filamentphp.com/api/3.x/Filament/FilamentManager.html#method_getModelResource
protected static function formatFailedRecords(Collection $failedRecords): string | ||
{ | ||
return collect($failedRecords) | ||
->map(function ($relatedRecords) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je kan hier ook fn () => ...
gebruiken
public function getRegisteredModelsWithFields(): Collection | ||
{ | ||
return $this->map(function ($formats, $model) { | ||
$fields = $formats->map(function (Format $format) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je kan hier ook fn (Format $format) => $format->column()
gebruiken
->unique() | ||
->values(); | ||
|
||
return (object) [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waarom return je hier een object en geen array? Array is makkelijker te typehinten dan een object.
$columns = Schema::getColumnListing($table); | ||
|
||
$model->fields->each(function ($field) use ($modelInstance, $record, $columns, &$records) { | ||
if (! in_array($field, $columns)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kan dit verplaatst worden naar een ->filter op de model->fields?
No description provided.