本文整理汇总了PHP中app\models\Article::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::all方法的具体用法?PHP Article::all怎么用?PHP Article::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Article
的用法示例。
在下文中一共展示了Article::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = Article::all();
// $data = compact('posts');
$data = ['posts' => $posts];
return view('blog', $data);
}
示例2: index
public function index()
{
$users = User::all()->count();
$trusts = Trusts::groupBy("registry")->get()->count();
$articles = Article::all()->count();
return view('admin/dashboard')->with(['users' => $users, 'trusts' => $trusts, 'articles' => $articles]);
}
示例3: laravel
public function laravel()
{
/*
* 查询所有的记录
* */
$list = \App\Models\Article::all()->toArray();
p($list);
/*
* 查询一条记录并转化为数组
$list = \App\Models\Article::first()->toArray();
p($list);
*/
/*
* 查询指定记录
*
$list = \App\Models\Article::find(1)->toArray();
p($list);
*/
/*
* 删除指定记录
$status = \App\Models\Article::where('id', '=', 11)->delete();;
p($status);
*/
// 更多请自己查看Eloquent ORM 开发手册
}
示例4: index
public function index()
{
$main_article = Article::all()->first();
$articles = Article::all();
$categories = ['branch', 'type', 'scope', 'theme', 'unit', 'settlor', 'fiduciary'];
$year_max = max(Trusts::select("year")->groupBy("year")->get()->toArray());
$year = $year_max["year"];
$definitions = Definitions::all();
$category = $definitions->where("name", "branch")->first();
$trusts = Trusts::groupBy("registry")->select("id", "branch", "type", "scope", "theme", "unit", "settlor", "fiduciary", 'income', 'yield', 'expenses', 'availability', 'initial_amount', 'year')->where("year", $year)->get();
return view('home')->with(['main_article' => $main_article, 'articles' => $articles, 'file_url' => '/images/articles/', 'months' => $this->months, 'trusts' => $trusts, 'categories' => $categories, 'category' => $category, 'definitions' => $definitions, 'year' => $year]);
}
示例5: index
public function index($api)
{
$articles = Article::all();
$output = '';
foreach ($articles as $post) {
$output .= $post->title;
$output .= ' ';
}
if ($api) {
return response()->json($output);
} else {
return $output;
}
}
示例6: getAllArticles
public function getAllArticles()
{
return Article::all();
}
示例7: function
$data->update(['article_title' => 'update test=3=.', 'feature' => false]);
// save方法
$data = \App\Models\Articles::where('id', '=', 11)->first();
$data->article_title = 'update test -3-.';
$data->feature = true;
$data->save();
}]);
Route::get('delete', ['as' => 'ORM.delete', function () {
$data = \App\Models\Articles::find(2);
$data->delete();
\App\Models\Articles::destroy(19, 20);
}]);
});
Route::get('test', function () {
// $data = \App\Models\Article::find(5);
$data1 = \App\Models\Article::all();
$data2 = \App\Models\Article::where('id', '>', 8);
$data3 = \App\Models\Article::orderBy('id', 'DESC');
dd([$data1, $data2, $data3]);
});
/*
Route::get('hello', function(){
return "Hello World!";
});
Route::get('post/{id}', function($id) {
return "id:".$id;
})->where('id', '[0-9]+');
// route name
Route::get('post2/{id?}', ['as' => 'post2.show', function($id = 0) {
示例8: index
public function index()
{
$articles = Article::all();
return view('admin.articles')->with('articles', $articles);
}
示例9: renderAll
/**
* @param int $number
* @return Collection
*/
public static function renderAll($number = 0)
{
/** @var Collection $all */
$all = Article::all();
if ($number > 0) {
$all = $all->random($number);
}
foreach ($all as $i) {
/** @var Article $i */
$i->append(['first_related_destination', 'thumbnail', 'view_url']);
}
return $all;
}
示例10: index
public function index()
{
return \View::make('admin.articles.index')->with('articles', Article::all());
}
示例11: all
public function all()
{
$articles = Article::all();
return view('reports')->with(['articles' => $articles, 'file_url' => '/images/articles/', 'months' => $this->months]);
}
示例12: index
public function index()
{
$articles = Article::all();
return $articles;
}
示例13: getIndex
public function getIndex()
{
$data = ['list' => Article::all()];
return View::make('admin.article', $data);
}
示例14: count
<ul class="sidebar-menu">
<li>
<a href="/">
<i class="glyphicon glyphicon-play-circle icon-sidebar"></i>START
</a>
</li>
<li>
<a href="/categories">
<i class="glyphicon glyphicon-th icon-sidebar"></i>Categories
</a>
<ul class="submenu">
<?php
$cats = \App\Models\Category::all();
$aNum = count(\App\Models\Article::all());
?>
<li><a style="color: #5bc0de;" href="/articles">All Articles <span class="label label-success span-sidebar">{{
$aNum
}}</span></a></li>
@if($cats)
@foreach($cats as $cat)
<li><a href="/category/{{ $cat->id }}">{{ $cat->name }}</a></li>
@endforeach
@else
<li><a href="javascript:;">...</a></li>
@endif
</ul>
</li>
<li>
<a href="/about">
<i class="glyphicon glyphicon-headphones icon-sidebar"></i>
<i class="fa fa-angle-right chevron-icon-sidebar"></i>
示例15: indexContent
public function indexContent()
{
return view('admin.index_content')->with('pages', Page::take(20)->get())->with('articleCats', ArticleCat::all())->with('articles', Article::all());
}