krafthaus / bauhaus

Laravel 4 Admin Generator
http://bauhaus.krafthaus.nl/
GNU General Public License v2.0
1 stars 0 forks source link

Filter to show only items created by user #34

Open crofton77 opened 10 years ago

crofton77 commented 10 years ago

How would I create a filter to only show items created by a user?

Also how would i set the user's id on save so it can be stored in database?

jspekken commented 10 years ago

You could do something like this:

public function configureFilters($mapper)
{
    $users = [];
    foreach (User::groupBy('email')->get() as $user) {
        $users[$user->email] = $user->email;
    }

    $mapper->select('email')->options($users);
}
crofton77 commented 10 years ago

This allows me to a user to filter by different users.

How do I make so the user can only see items they created?