any help please!!
Aug 22, 2017
3
Level 1
Can't use pagination on hasMany relationship...
here is my controller..
namespace App\Http\Controllers\Frontend;
use App\Category; use App\Gallery;
use App\images; use Illuminate\Http\Request; use App\Http\Controllers\Controller;
class GalleryController extends Controller {
public function index(Gallery $gallery,images $image ){
$galleries=$gallery->with('images')->get();
$categories=Category::all();
//to view only the list of galleries created by the user
// $galleries=Gallery::where('created_by', Auth::user()->id)->get(); return view('frontend.gallery',compact('galleries','paginate','categories'));
}
}
here is my model
namespace App;
use Illuminate\Database\Eloquent\Model;
class Gallery extends Model {
protected $table='gallery';
protected $fillable=['name','category_id'];
public function images(){
return $this->hasMany('App\images');
}
public function category(){
return $this->belongsTo('App\Category');
}
}
how can i paginate all images in the gallery...
Please or to participate in this conversation.