cache->getOrSet("site-stories",function (){
$data = [];
$news = News::find()->limit(10);
foreach ($news->all() as $news_item)
{
/**
* @var $news_item News
*/
$comments = [];
foreach ($news_item->getCommentsAll()->limit(5)->all() as $comment){
/**
* @var $comment \app\models\base\Comments
*/
$comments[]=[
"message"=>$comment->message,
"published_at"=>$comment->publishedAt
];
}
$data[]=[
"id"=>$news_item->uid,
"photo"=>$news_item->preview->getUrl(\app\models\base\Image::SIZE_680x383),
"name"=>false,
"link"=>$news_item->url,
"lastUpdated"=>strtotime($news_item->dt_pub),
"seen"=>false,
"published_at"=>$news_item->publishedAt,
"items"=>[
[
"id"=>$news_item->preview->getUrl(\app\models\base\Image::SIZE_680x383),
"type"=>"photo",
"length"=>100,
"lastUpdated"=>strtotime($news_item->dt_pub),
"src"=>$news_item->preview->getUrl(\app\models\base\Image::SIZE_1040x586),
"preview"=>$news_item->preview->getUrl(\app\models\base\Image::SIZE_680x383),
"link"=>$news_item->url,
"linkText"=>$news_item->lid,
"seen"=> false,
"lid"=>$news_item->lid,
"post_title"=>$news_item->title,
"comments"=>base64_encode(json_encode($comments))
]
]
];
}
return json_encode($data);
},1);
?>