Hello everyone,
sorry for the not-so-explicit title, I couldn't find a better way to phrase it. I'm using a standalone version of Eloquent with a little Slim PHP forum I'm building.
I have a Board object with has a hasMany relationship with the topics that have been posted in that board. I'm using a pagination system and passing the current page number to the URL, to calculate the LIMIT and OFFSET (or skip() and take() with the query builder).
Here's my code at hte moment :
$perPages = 15;
$pageOffset = ($page - 1) * $perPages;
// Get the board from the slug
$board = Board::with(array('topics' => function($query, $perPages, $pageOffset){
$query->skip($pageOffset)->take($perPages);
}))->where("slug", $slug)->first();
$page is the page number which I take from the URL.
How can I pass the $perPages and $pageOffset variables to the closure? I tried adding them as extra parameters as shown below, but I'm getting this error :
Missing argument 2 for {closure}()