本文整理汇总了PHP中app\Article::take方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::take方法的具体用法?PHP Article::take怎么用?PHP Article::take使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::take方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$art_id = (int) Input::get('id', 0);
if ($art_id) {
$article = Article::find($art_id);
} else {
$article = Article::take(1)->skip(0);
}
$currarticle = $article->join('article_contents', 'article_contents.article_id', '=', 'articles.id')->get(['articles.*', 'article_contents.title', 'article_contents.content'])->first()->toArray();
\Mesa::prr($currarticle, 55);
$topicarr = Menu::find($currarticle['menu_id'])->topics()->orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
$topics = $this->clubarr($topicarr);
$allmenus = Menu::orderBy('level', 'ASC')->orderBy('title', 'ASC')->get()->toArray();
$menus = $this->clubarr($allmenus);
$viewarr = array('article' => $currarticle, 'topics' => $topics, 'menus' => $menus);
return view('civil.article.index')->with($viewarr);
}
示例2: getFever
//.........这里部分代码省略.........
}
$feeds_groups[$key]['feed_ids'] = implode(',', $feed_ids);
}
}
}
$response_arr['feeds_groups'] = $feeds_groups;
$arr = array_merge($arr, $response_arr);
}
//return list with all unread article id's
if (isset($_GET['unread_item_ids'])) {
$unread_item_ids = [];
$Articles = Article::where('status', 'unread')->orderBy('id', 'asc')->get();
if (!empty($Articles)) {
foreach ($Articles as $Article) {
array_push($unread_item_ids, $Article->id);
}
}
//string/comma-separated list of positive integers instead of array
$stack = implode(',', $unread_item_ids);
$unreaditems = ['unread_item_ids' => $stack];
$arr = array_merge($arr, $unreaditems);
}
//return string/comma-separated list with id's from read and starred articles
if (isset($_GET['saved_item_ids'])) {
$saved_item_ids = [];
$Articles = Article::where('star_ind', '1')->orderBy('id', 'asc')->get();
if (!empty($Articles)) {
foreach ($Articles as $Article) {
array_push($saved_item_ids, $Article->id);
}
}
//string/comma-separated list of positive integers instead of array
$stack = implode(',', $saved_item_ids);
$saveditems = ['saved_item_ids' => $stack];
$arr = array_merge($arr, $saveditems);
}
//when argument is items, return 50 articles at a time
if (isset($_GET['items'])) {
$total_items = [];
$total_items['total_items'] = Article::count();
$arr = array_merge($arr, $total_items);
$items = [];
//request specific items, a maximum of 50 specific items requested by comma-separated argument
if (isset($_GET['with_ids'])) {
//list with id's is comma-separated, so transform to array
$ArrayIds = explode(',', $_REQUEST['with_ids']);
//create empty array to store Article results
$Articles = [];
if (!empty($ArrayIds)) {
foreach ($ArrayIds as $ArrayId) {
$Article = Article::find($ArrayId);
array_push($Articles, $Article);
}
}
//request 50 additional items using the highest id of locally cached items
} elseif (isset($_REQUEST['since_id'])) {
$Articles = Article::where('id', '>', $_REQUEST['since_id'])->orderBy('id', 'asc')->take(50)->get();
//request 50 previous items using the lowest id of locally cached items
} elseif (isset($_REQUEST['max_id'])) {
$Articles = Article::where('id', '<', $_REQUEST['max_id'])->orderBy('id', 'asc')->take(50)->get();
//if no argument is given provide total_items and up to 50 items
} else {
$Articles = Article::take(50)->orderBy('id', 'asc')->get();
}
if (!empty($Articles)) {
foreach ($Articles as $Article) {
array_push($items, ['id' => (int) $Article->id, 'feed_id' => (int) $Article->feed_id, 'title' => $Article->subject, 'author' => $Article->author, 'html' => $Article->content, 'url' => $Article->url, 'is_saved' => (int) $Article->star_ind, 'is_read' => $Article->status == 'read' ? 1 : 0, 'created_on_time' => strtotime($Article->published)]);
}
}
$response_arr['items'] = $items;
$arr = array_merge($arr, $response_arr);
}
//when argument is links, don't return anything at this moment
if (isset($_GET['links'])) {
$links = [];
$response_arr['links'] = $links;
$arr = array_merge($arr, $response_arr);
}
//when argument is groups, retrieve list with categories and id's
if (isset($_GET['favicons'])) {
$favicons = [];
$Feeds = Feed::orderBy('feed_name', 'asc')->get();
if (!empty($Feeds)) {
foreach ($Feeds as $Feed) {
if (empty($Feed->favicon)) {
//TODO: replace with Laravel's URL functionality
$faviconurl = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$faviconurl = substr($faviconurl, 0, strpos($faviconurl, 'index.php/api')) . 'img/rss-default.png';
} else {
$faviconurl = $Feed->favicon;
}
array_push($favicons, ['id' => (int) $Feed->id, 'title' => $faviconurl]);
}
$response_arr['favicons'] = $favicons;
$arr = array_merge($arr, $response_arr);
}
}
//return fever response
return response()->json($arr);
}
示例3: listing
public function listing()
{
//$articles=Article::paginate(5);
// return view('articles.listing')->withArticles($articles);
return view('articles.listing')->withArticles(Article::take('all')->orderBy('created_at', 'desc')->paginate(5));
}