public function view()
{
$posts = DB::table('posts')
->select('*')
->get('*');
foreach ($posts as $post) {
echo $post->id.'<br>';
return Response::json([
'posts'=>
[
'title'=>$post->title,
'datatime'=>$post->datetime,
'anons'=>$post->anons,
'text'=>$post->text,
'tags'=>explode(', ', $post->tags),
'image'=>$post->images
]
]);
}
}
public function view()
{
$posts = DB::table('posts')
->select('*')
->get('*');
return Response::json([
'posts' => array_map(function($post) {
return [
'title'=>$post->title,
'datatime'=>$post->datetime,
'anons'=>$post->anons,
'text'=>$post->text,
'tags'=>explode(', ', $post->tags),
'image'=>$post->images
];
}, $posts)
]);
}