Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

Actually, I think I solved it. I was looking in the wrong part of the documentation.

This seems to work:

$query = Profile::with('user', 'rank', 'game', 'roles', 'gamemodes', 'characters')
    ->whereHas('user', function($query)
    {
      if(\Request::get('name'))
        $query->where('name', 'LIKE', '%' . \Request::get('name') . '%');
    })
    ->get();

Will come back, if this isn't the case after all.

0

Bonus Update:

I just realized that if I getXAttribute() I can then append this on my object and don't have to use ->with(). Which allows me to use the built in pagination

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.