本文整理汇总了PHP中app\models\News::all方法的典型用法代码示例。如果您正苦于以下问题:PHP News::all方法的具体用法?PHP News::all怎么用?PHP News::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\News
的用法示例。
在下文中一共展示了News::all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: frontendIndex
public function frontendIndex(Request $request)
{
$page = $request->input('page', 1);
$limit = 20;
$offset = ($page - 1) * $limit;
$result = News::offset($offset)->take($limit)->get();
$result1 = DB::table('parent_menu')->get();
$siteTitle = Setting::where('name', 'title')->get();
if (count($siteTitle) > 0) {
$bah = $siteTitle->first()->value;
} else {
$bah = 'Website';
}
$footer = Setting::where('name', 'footer')->get();
if (count($footer) > 0) {
$footer = $footer->first()->value;
} else {
$footer = '(c) 2015, Ordent, All Right Reserved.';
}
$logo = Setting::where('name', 'logo')->get();
if (count($logo) > 0) {
$logo = asset('/uploads/logo/') . '/' . $logo->first()->value;
$logo = preg_replace('/\\s+/', '', $logo);
} else {
$logo = '#';
}
$count = ceil(count(News::all()) / 20);
return view('frontend.news-index', compact('result', 'title', 'result1', 'footer', 'count', 'logo'));
}
示例2: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$news = News::all()->where('status_id', 3);
return view('front.news.index', compact('news'));
}
示例3: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
return $news = News::all();
return $news;
}
示例4: admin
/**
* Display a listing of the resource in administration side.
*
* @return Response
*/
public function admin()
{
$news = News::all();
return view('news.backend.index', compact('news'));
}
示例5:
<br/><br/>
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Title</th>
<th width="30%">Category</th>
<th width="10%">Edit</th>
<th width="10%">Delete</th>
</tr>
</thead>
<tbody>
<?php
use App\Models\News;
use App\Models\Category;
$news = News::all();
?>
@foreach ($news as $item)
<tr>
<td><?php
echo $item->nTitle;
?>
</td>
<td><?php
echo Category::find($item->catId)->catName;
?>
</td>
<td><a href="{{URL::to('news/edit',$item->nId)}}">Edit</a></td>
<td><a href="{{URL::to('deleteNews',$item->nId)}}" onclick="if(!confirm('Are you sure to delete this item?')){return false;};" title="Delete this Item">Delete</a></td>
</tr>
@endforeach