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

Has many relationship does not load existing values #624

Closed
janhenkes opened this issue Oct 18, 2024 · 2 comments · Fixed by #630
Closed

Has many relationship does not load existing values #624

janhenkes opened this issue Oct 18, 2024 · 2 comments · Fixed by #630
Labels

Comments

@janhenkes
Copy link

Description

I have two models: Organization and OrganizationShippingAddress. On the Organization I have an HasMany relation for shipping addresses:

public function shippingAddresses(): HasMany
{
   return $this->hasMany(OrganizationShippingAddress::class);
}

In the organization.yaml blueprint I created the following field:

tabs:
  shipping_addresses:
    display: 'Shipping addresses'
    sections:
        fields:
          -
            handle: shipping_addresses
            field:
              resource: organization_shipping_address
              relationship_name: shippingAddresses
              type: has_many
              display: 'Shipping addresses'
              sortable: false

I expect to see the existing related models, but they don't show. I can select other models and create new ones, but after I save the organization the related models do not show up in the field.

Steps to reproduce

  1. Create two models with an HasMany relationship
  2. Add the HasMany field to model A
  3. Create related models directly in the database
  4. See if they show up in the field

Environment

Fatal error: Uncaught Error: Class "App\Console\Kernel" not found in vendor/statamic/cms/src/Console/Please/Kernel.php:11

I use Statamic 5.31, Laravel 11.27 and Runway 7.11

@janhenkes janhenkes added the bug label Oct 18, 2024
@duncanmcclean
Copy link
Member

That's strange. They should be showing - I'll take a look when I'm back on Runway.

Fatal error: Uncaught Error: Class "App\Console\Kernel" not found in vendor/statamic/cms/src/Console/Please/Kernel.php:11

You'll need to update your please file after updating to Laravel 11: https://statamic.dev/upgrade-guide/4-to-5#updated-please-file-for-laravel

Copy link

github-actions bot commented Nov 4, 2024

Released as part of v7.12.0.

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

Successfully merging a pull request may close this issue.

2 participants