Because I'm very tired of repeating ...->$paginate()->setPageName('seite') on most of the Controller's index() methods, I created the following helper function:
if (! function_exists('paginate')) {
function paginate(\Illuminate\Database\Eloquent\Builder $builder)
{
return $builder->paginate()->setPageName('seite');
}
}
So now I can use it like this:
public function index()
{
// before:
// $companies = Company::orderBy('name')->paginate()->setPageName('seite');
// after:
$companies = paginate(Company::orderBy('name'));
return view('companies.index', compact('companies'));
}
If anyone knows about a better solution, I'd be glad to see this :)