Skip to content

HasMany-Relation with a static field (model_type) #55848

Closed Answered by Cluster2a
Cluster2a asked this question in Q&A
Discussion options

You must be logged in to vote

I came to another solution, which might not be perfect in general but works for our use cases:

<?php

declare(strict_types=1);

namespace App\Freispace\CustomFields\Traits;

use App\Freispace\CustomFields\Models\GlobalField;
use App\Freispace\CustomFields\Models\GlobalFieldResponse;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use InvalidArgumentException;

/**
 * Trait LoadsGlobalFields
 *
 * This trait provides functionality to load global fields for models.
 * It supports loading fields for individual models and collections.
 *
 * @property-read Collection $global_fields
 */
trait LoadsGlobalFields
{
     /**
     * Load global fields for the giv…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@shaedrich
Comment options

@soheylfarzane
Comment options

@soheylfarzane
Comment options

@shaedrich
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Cluster2a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants