public static function feedsID($post_id) { $ids = array(); foreach (FeedPost::where('post_id', $post_id)->get() as $record) { $ids[] = $record->feed_id; } return $ids; }
public function topost($id) { $post = Post::find($id); if ($post) { switch ($post->taxonomy_id) { case 1: $uri = Post::getFullURI($post->id, true); return Redirect::to($uri); case 2: $feed = FeedPost::where('post_id', $post->id)->first(); if ($feed) { $page = Post::where('feed_id', $feed->feed_id)->first(); if ($page) { $viewmods = WebAPL\Template::getViewMethodList('page'); $uri = Post::getFullURI($page->id, true); if (isset($viewmods[$page->view_mod]['support_item']) && $viewmods[$page->view_mod]['support_item']) { $plang = PostLang::where('post_id', $post->id)->where('lang_id', \WebAPL\Language::getId())->first(); if ($plang) { $url = $uri . "?item=" . $plang->uri; } else { $url = $uri; } } else { $url = $uri; } return Redirect::to($url); } else { throw new Exception("Not found page, post #{$id}"); } } else { throw new Exception("Not found feed, post #{$id}"); } break; default: throw new Exception("Not found taxonomy, post #{$id}"); break; } } else { throw new Exception("Post not found #{$id}"); } }
public function postDeletefeed() { $id = Input::get('id'); Feed::where('id', $id)->delete(); FeedPost::where('feed_id', $id)->delete(); FeedRel::where('feed_id', $id)->delete(); return Redirect::to('feed'); }
public static function getYears($feed_id) { return Post::join(FeedPost::getTableName(), FeedPost::getField('post_id'), '=', Post::getField('id'))->distinct()->orderBy(Post::getField('created_at'), 'desc')->select(DB::raw("YEAR(" . Post::getField('created_at') . ") as year"))->where(FeedPost::getField('feed_id'), '=', $feed_id)->get(); }
public static function getPostCount($feed_id) { return Feed::join(FeedPost::getTableName(), FeedPost::getField('feed_id'), '=', Feed::getField('id'))->where(FeedPost::getField('feed_id'), '=', $feed_id)->count(); }
public static function FBPostToFeed($intUserId, $arrParams, $strTag = null) { $objFeedPost = new FeedPost(); $objFeedPost->IdApp = SApplication::AppName(); $objFeedPost->SenderFbuid = self::FBUid(); $objFeedPost->ReciverFbuid = $intUserId; $objFeedPost->Data = json_encode($arrParams); $objFeedPost->CreDate = QDateTime::Now(); $objFeedPost->Tag = $strTag; $objFeedPost->Save(); $strCall = sprintf('/%s/feed', $intUserId); return self::FB($strCall, $arrParams); }
public static function findExistsDates($feed_id) { $posts = Post::prepareQuery(2)->join(FeedPost::getTableName(), Post::getField("id"), '=', FeedPost::getField("post_id"))->where(FeedPost::getField("feed_id"), $feed_id)->where(PostLang::getField('enabled'), 1)->where(Post::getField('is_trash'), 0)->orderBy(DB::raw("DATE(" . Post::getField('created_at') . ")"), 'asc')->select(DB::raw("DATE(" . Post::getField('created_at') . ") as data"))->remember(SettingsModel::one('cachelife'))->get(); $dates = ['years' => [], 'months' => []]; foreach ($posts as $post) { $tmst = strtotime($post->data); $y = (int) date("Y", $tmst); $m = (int) date("m", $tmst); $d = (int) date("d", $tmst); $dates['years'][$y] = $y; if (isset($dates['months'][$y])) { if (isset($dates['months'][$y][$m])) { $dates['months'][$y][$m]++; } else { $dates['months'][$y][$m] = 1; } } else { $dates['months'][$y] = [$m => 1]; } } return $dates; }