Search code examples
laraveleloquent-relationshiplaravel-7

Laravel Many To Many Relationship with unwanted limit of 250


I've a Many To Many Relationship

users
    id - integer
    name - string

apps
    id - integer
    steam_id - integer (ID for this app on steam)
    name - string

app_user
    user_id - integer
    app_id - integer

My user modal

    public function apps()
    {
        return $this->belongsToMany(App::class, 'app_user');
    }

My app modal

    public function users()
    {
        return $this->belongsToMany(User::class, 'app_user');
    }

Now I want to output the apps from a user, which basically works in several methods.

$user->apps()->get()

$user->apps()->inRandomOrder()->get();

$user->apps()->orderBy('name')->get()

$user->apps()->limit(50)->get()

But no matter what I do, I always get only 250 entries back, although this user has 1072 entries. Where is this limit 250 set and how can I increase or decrease it?


Solution

  • The mistake was once again quite simple. Kurt Friars gave me the right mental impulse.. I adapted the migration for the overview and my mistake was that I used the ID of Steam with ->sync([]) and not the ID of the apps table.

    Thank you all and have a nice weekend.