<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Providers extends Model
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'status',
'name',
'access_hours',
'access_info'
];
/**
* Get the user(s) associated with the provider.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function users()
{
return $this->belongsToMany('App\User');
}
}
from my view and leave paginate(3) in my controller, it works, it will only give me 3 results, if I change it to 4, it will give me 4, it's just the stupid render() method thats for what ever reason not being found...
That is odd... This should work fine.. Have you tried to run composer dump-autoload -o or removing your vendor directory and running composer install again? Might be something that is not loaded correctly. I have no clue what else it could be...
Is that a large project? Your code is perfectly fine, so it must be either some service provider or view composer screwing it up, or some lower level issue.
I'm not sure but default Eloquent return Eloquent list, that's why it doesn't have render method, There are ony 2 objects that have that methods are Illuminate\Pagination\Paginator and Illuminate\Pagination\LengthAwarePaginator.
If you have created your own custom service provider, did you consider registering it in the config/app.php along with the other application service providers?
I had the same issue, using 5.1, and as the last post suggested the error had to do with modifying the collection. In my case I originally used a sortBy after calling paginate. Once I removed the sortBy it worked as expected.
I had a similar problem. This issue was that paginate() didn't actually change my collection into a paginator object, but it returns a paginator object.
Actually, I just made a bit of progress with figuring this out.
I got the exact same errors, but it was because I was passing the collection to a partial view to display the results via an @include. the I tried to pass the collection to @include but it still didn't work.
I pulled all of the markup out of the partial and put it in the main view and suddenly the pagination links worked beautifully. But it was not working when nested in an include, despite me trying to push it there with the second argument of @include.
Sorry, typing this on zero sleep, haha. Hopefully that helps someone else.