Oh sorry my bad, i made it work. Thanks!
However, how to send custom methods from User too?
You would first need to get the Collection without the toJSON() and perform your methods, then use toJSON() on your method outputs.
$usersArticles = User::all()->with('Articles');
foreach($usersArticles as $userArticle) {
echo $userArticle->myCustomUserMethod();
}
or
echo $userArticle->myCustomUserMethod()->toJSON();
if it outputs an object/array.
public function ajaxScroll() { $take = Input::get('take'); $skip = Input::get('skip');
$articles = Article::orderBy('created_at', 'desc')
->take($take)
->skip($skip)
->with('user', 'votes')
->get()
->toJson();
return $articles;
}
How to do that in my case?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community