本文整理匯總了PHP中app\News::take方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::take方法的具體用法?PHP News::take怎麽用?PHP News::take使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\News
的用法示例。
在下文中一共展示了News::take方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
try {
$isInstalled = Setting::where('name', 'is_installed')->firstOrFail();
} catch (ModelNotFoundException $e) {
$isInstalled = Setting::create(['name' => 'is_installed', 'setting' => 'no']);
}
if ($isInstalled->setting != 'yes') {
return Redirect::route('install');
}
$data = ["event" => Event::first(), "upcomingEvents" => Event::take(3)->get(), "news" => News::take(6)->get(), "media" => Media::where('processed', true)->orderBy('id', 'DESC')->take(12)->get()];
return view('home')->with($data);
}
示例2: showall
public function showall()
{
$items = Items::orderBy('created_at', 'desc')->get();
$categories = DB::table('categories')->get();
foreach ($items as $item) {
$r = DB::table('sub_categories')->select('categories_id')->where('id', $item->sub_categories_id)->get();
$item['category'] = $r[0]->categories_id;
}
$news = News::take(3)->get();
return view('index', ['categories' => $categories, 'items' => $items, 'news' => $news]);
}