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

THE001-90 handle exception for foreign key constraints #42

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

thibautdeg
Copy link
Contributor

No description provided.

$resourceClass = get_class($model);

$filamentResource = collect(Filament::getResources())
->first(function ($filamentResource) use ($resourceClass) {
Copy link
Member

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) {
Copy link
Member

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')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected static function formatFailedRecords(Collection $failedRecords): string
{
return collect($failedRecords)
->map(function ($relatedRecords) {
Copy link
Member

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) {
Copy link
Member

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) [
Copy link
Member

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)) {
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants