79489017

Date: 2025-03-06 10:37:35
Score: 0.5
Natty:
Report link

you can specify what relations to load based on the type of morph parent

docs: https://laravel.com/docs/11.x/eloquent-relationships#nested-eager-loading-morphto-relationships

Mission::query()
  ->with(['modality' => function (MorphTo $morphTo) {
        $morphTo->morphWith([
            AnnualStatementModality::class => ['company', 'fiscal_year'],
            NewCompanyModality::class => ['fiscal_year'],
            /** other cases as needed */
        ]);
    }])
Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
Posted by: kris gjika