/** * 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); }
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]); }
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 开发手册 }
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]); }
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; } }
public function getAllArticles() { return Article::all(); }
$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) {
public function index() { $articles = Article::all(); return view('admin.articles')->with('articles', $articles); }
/** * @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; }
public function index() { return \View::make('admin.articles.index')->with('articles', Article::all()); }
public function all() { $articles = Article::all(); return view('reports')->with(['articles' => $articles, 'file_url' => '/images/articles/', 'months' => $this->months]); }
public function index() { $articles = Article::all(); return $articles; }
public function getIndex() { $data = ['list' => Article::all()]; return View::make('admin.article', $data); }
<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>
public function indexContent() { return view('admin.index_content')->with('pages', Page::take(20)->get())->with('articleCats', ArticleCat::all())->with('articles', Article::all()); }
/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { return view('backend.article.edit')->with(['item' => Article::find($id), 'types' => Article::all()]); }
/** * Render the articles view * * @return \Illuminate\View\View */ public function index() { return view('articles/index', array('articles' => Article::all())); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $this->setMetaTitle('Blog'); $articles = Article::all(); return view('articles.index', compact('articles')); }