本文整理汇总了PHP中app\Article::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::all方法的具体用法?PHP Article::all怎么用?PHP Article::all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Article
的用法示例。
在下文中一共展示了Article::all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
$pagesAll = Page::all();
$articlesAll = Article::all();
$templatesAll = Template::all();
$contentAreasAll = ContentArea::all();
$content_areas = ContentArea::lists('name', 'id');
$pages = Page::lists('name', 'id');
$article = Article::findOrFail($id);
return view('site.edit', compact('article', 'pages', 'content_areas', 'pagesAll', 'articlesAll', 'templatesAll', 'contentAreasAll'));
}
示例2: forUser
/**
* Get all of the articles for a given user.
**
*
* @return mixed
*/
public function forUser()
{
if ($this->user->is_admin) {
return $this->article->all()->sortBy('created_at');
}
return $this->article->where('user_id', $this->user->id)->orderBy('created_at', 'asc')->get();
}
示例3: run
public function run()
{
$article = Article::all()->first();
DB::table('places')->delete();
$place = Place::create(array('name' => 'Innocenti Evasioni', 'url' => 'http://www.innocentievasioni.com/', 'address' => 'Via Privata della Bindellina, 20155 Milano', 'lat' => '45.492522', 'lng' => '9.149578', 'status' => Place::GEOLOCALIZED));
$article->places()->attach($place);
}
示例4: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
$teachers = Teacher::topN(6);
$articles = Article::all();
$categories_in_pane = ArticleCategory::all();
return response()->view('site.colabor', array('teachers' => $teachers, 'other_articles' => $articles, 'categories_in_pane' => $categories_in_pane));
}
示例5: index
public function index(Request $request)
{
$output = Article::all();
// $url = $request->url();
// dd($url);
return view('articles.index', compact('output'));
}
示例6: getArticle
public function getArticle($cate, $arti)
{
$arti = substr($arti, 0, -5);
//cắt chuối ".html" cuối article alias
$category = Category::where("category_alias", $cate)->first();
//lấy category đầu tiên có alias bằng tham số category alias
$listCategory = Category::all(["id", "category_alias", "category_name"])->toArray();
$allArticles = Article::all(["id", "title", "alias", "summary", "content", "image", "category_id", "author", "created_date"])->where('category_id', $category["id"])->toArray();
//lấy tất cả bài viết trong category
if ($category != null) {
$message = "";
$category_name = $category["category_name"];
if (count($allArticles) == 0) {
$message = 'Không có bài viết nào.';
} else {
$article = Article::where("alias", $arti)->first();
if ($article != null) {
$relateArticles = Article::where('category_id', $category["id"])->where("id", '!=', $article["id"])->orderBy('created_date', 'desc')->get()->take(2)->toArray();
return view('front.blog.article', compact('listCategory', 'relateArticles', 'message', 'category_name', 'article', 'mess'));
} else {
$message = "Không tìm thấy bài viết phù hợp";
return view('front.blog.error', compact('listCategory', 'message', 'category_name'));
}
}
return view('blog.index', compact('listCategory', 'message', 'category_name'));
}
}
示例7: welcome
public function welcome()
{
$id = 1;
$parent = Cate::select('id', 'name', 'parent_id')->where('catetype_id', $id)->get()->toArray();
$article = Article::all();
return view('welcome', compact('parent', 'article'));
}
示例8: index
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
// return view('Admin')->withPages(Page::all());
// return view('Admin',['pages'=>Page::all()]);
return view('Admin')->with('pages', Page::all())->with('articles', Article::all());
// $pages['pages'] = Page::all();
// return view('Admin',$pages);
}
示例9: listArticle
public function listArticle()
{
$article = new Article();
$list = $article->all()->toArray();
return view('admin.article.index')->with('listArticle', $list);
//có thể có cách khác assign biến ra
//return view('article.index',compact('list')); <== phần này ở ngoài sẽ đọc luôn cái list
}
示例10: index
public function index()
{
$articles = Article::all();
if (Request::wantsJson()) {
return $articles;
}
return view('articles.index', compact('articles'));
}
示例11: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->composer('partials._blog-aside', function ($view) {
$view->with('postDate', Article::all()->groupBy(function ($date) {
return Carbon::parse($date->created_at)->format('M-y');
}));
$view->with('tags', Tag::all());
});
}
示例12: index
public function index()
{
if (!Auth::check()) {
return redirect('/');
}
$users = User::all();
$articles = Article::all();
return view('auth.profil', compact('users', 'articles'));
}
示例13: testCreateAndList
public function testCreateAndList()
{
$articleCount = 10;
for ($i = 1; $i <= $articleCount; $i++) {
Article::create(['title' => 'subject ' . $i, 'body' => 'body ' . $i]);
}
$articles = Article::all();
$this->assertEquals($articleCount, count($articles));
}
示例14: index
/**
* Show the application dashboard.
*
* @return Response
*/
public function index()
{
$articleCount = Article::all()->count();
$partTypeCount = PartType::all()->count();
$brandsCount = Brand::all()->count();
$modelCount = BrandModel::all()->count();
// dd($articleCount);
return view('home')->with(['articleCount' => $articleCount, 'partTypeCount' => $partTypeCount, 'brandsCount' => $brandsCount, 'modelCount' => $modelCount]);
}
示例15: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
$article = new Article();
$article->body = $request->input('body');
$article->title = $request->input('title');
$article->save();
$articles = Article::all();
dd($articles);
}