Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

Check scopes on this link: http://laravel.com/docs/eloquent#query-scopes

This way you can query your database and select only projects which are visible to user

Last updated 2 years ago.
0

Currently I'm building my view this way:

@foreach($customers as $customer)
                                <tr class="ignore-from-filtering">
                                    <td colspan="6"><strong> {{ $customer->name }}</strong> ({{ $customer->projects->count() }})</td>
                                </tr>
                                @foreach($customer->projects as $project)
/* ... */

So, where to implement the scopes?

Last updated 2 years ago.
0

You will probably want to check out: http://laravel.com/docs/eloquent#eager-loading ("Eager Load Constraints")

and/or

http://laravel.com/docs/eloquent#query-scopes

Last updated 2 years ago.
0

Are there any examples out there for scopes? I can't figure out, how they really work :/

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

nehalist nehalist Joined 24 Feb 2014

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.