当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::with方法代码示例

本文整理汇总了PHP中app\Article::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::with方法的具体用法?PHP Article::with怎么用?PHP Article::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Article的用法示例。


在下文中一共展示了Article::with方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     //		TODO: abstract to model
     $sliders = Photo::join('photo_albums', 'photo_albums.id', '=', 'photos.photo_album_id')->where('photos.slider', 1)->orderBy('photos.position', 'DESC')->orderBy('photos.created_at', 'DESC')->select('photos.filename', 'photos.name', 'photos.description', 'photo_albums.folder_id')->get();
     $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $categoriesArray = Object::where('type', 'category')->get();
     $categories = array();
     foreach ($categoriesArray as $category) {
         $categories[] = array($category->title);
     }
     $categories = Object::where('type', 'category')->get();
     global $types;
     $types = Object::getTypes()->select(array('id', DB::raw("REPLACE(name, '_object_type_', '') as name"), DB::raw("REPLACE(title, 'Object Type: ', '') as title"), 'created_at'))->get();
     return view('pages.home', compact('articles', 'sliders', 'videoAlbums', 'photoAlbums', 'categories', 'types'));
     //return view('pages.welcome');
 }
开发者ID:Avimunk,项目名称:jini_1,代码行数:23,代码来源:HomeController.php

示例2: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from photos WHERE album_cover=TRUE and photos.photo_album_id=photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from photos WHERE photos.photo_album_id=photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from videos WHERE album_cover=TRUE and videos.video_album_id=video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from videos WHERE videos.video_album_id=video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     return view('pages.home', compact('articles', 'videoAlbums', 'photoAlbums'));
 }
开发者ID:nickeblewis,项目名称:Laravel-5-Bootstrap-3-Starter-Site,代码行数:12,代码来源:HomeController.php

示例3: getArticolo

 public function getArticolo($slug)
 {
     // dettaglio di un singolo articolo
     //$categories = \App\Category::all();
     $article = \App\Article::with('categories', 'user')->where('slug', '=', $slug)->first();
     return view('blog.article', compact('article'));
 }
开发者ID:haseo2015,项目名称:laravel,代码行数:7,代码来源:FrontendController.php

示例4: query

 /**
  * Get the query object to be processed by datatables.
  *
  * @return \Illuminate\Database\Query\Builder|\Illuminate\Database\Eloquent\Builder
  */
 public function query()
 {
     $articles = Article::with('category')->whereHas('category', function ($q) {
         $q->where('language_id', session('current_lang')->id);
     });
     return $this->applyScopes($articles);
 }
开发者ID:boynoiz,项目名称:laravel-5-simple-cms,代码行数:12,代码来源:ArticleDataTable.php

示例5: index

 public function index(Request $request)
 {
     $orderby = $request->orderby ? $request->orderby : 'created_at';
     $articles = Article::with('user')->Orderby($orderby, 'DESC')->simplePaginate(10);
     // $articles = $this->articles->allWithNotActived();
     return view('admin.articles.index', compact('articles', 'orderby'));
 }
开发者ID:litemax,项目名称:LaravelBlog,代码行数:7,代码来源:ArticleController.php

示例6: index

 public function index(Request $request)
 {
     $orderby = $request->orderby ? $request->orderby : 'created_at';
     $title = $request->title ? $request->title : '';
     $articles = Article::with('user')->whereTitle($title)->Orderby($orderby, 'DESC')->simplePaginate(10);
     return view('admin.articles.index', compact('articles', 'orderby', 'title'));
 }
开发者ID:misterebs,项目名称:cmsku,代码行数:7,代码来源:ArticleController.php

示例7: get

 public function get($id)
 {
     $article = Article::with('tags')->find($id);
     if (!$article) {
         return response()->json(null, 404);
     }
     return response()->json($article);
 }
开发者ID:valiknet18,项目名称:FootballNewsApp,代码行数:8,代码来源:ArticlesController.php

示例8: recent

 protected function recent()
 {
     view()->composer('widgets.recent', function ($view) {
         $view->with('articles', Cache::remember('widgets_recent', 10, function () {
             return Article::with('tags', 'category')->public()->orderby('published_at', 'desc')->take(5)->get();
         }));
     });
 }
开发者ID:angelWendy,项目名称:streamlet,代码行数:8,代码来源:ComposerServiceProvider.php

示例9: index

 /**
  * Display a listing of the articles.
  *
  * @return Response
  */
 public function index()
 {
     $page_size = env('num_per_page');
     //take: set the limit of the query
     //get: Execute the query as a "select" statement.
     $articles = \App\Article::with('tags', 'category')->published()->orderBy('updated_at', 'desc')->take($page_size)->get();
     return view('blog.index', compact('articles'));
 }
开发者ID:ambarsetyawan,项目名称:laravel5-blog-1,代码行数:13,代码来源:HomeController.php

示例10: articleSearcher

 public function articleSearcher()
 {
     $modelsList = BrandModel::lists('name', 'id')->prepend('(all)', '');
     $brandsList = Brand::lists('name', 'id')->prepend('(all)', '');
     $partsList = PartType::lists('name', 'id')->prepend('(all)', '');
     $articles = Article::with('articleType', 'brand', 'model', 'partType')->orderBy('name', 'asc')->get();
     return view('backoffice.articles.ArticleSearcher')->with(compact('modelsList'))->with(compact('brandsList'))->with(compact('partsList'))->with(compact('articles'));
 }
开发者ID:zekaroz,项目名称:Opel,代码行数:8,代码来源:ArticlesController.php

示例11: index

 /**
  * Returns a view of all articles in the system
  *
  * @return \Illuminate\View\View
  */
 public function index()
 {
     $articles = array();
     foreach (Article::with('user')->with('template')->get() as $article) {
         array_push($articles, $article);
     }
     //return $articles;
     return view('admin.articles.index', compact('articles'));
 }
开发者ID:bstapleton,项目名称:pi-community,代码行数:14,代码来源:ArticleController.php

示例12: show

 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return Response
  */
 public function show($slug)
 {
     //$articles = Tag::findBySlug($slug)->articles()->latest('articles.created_at')->paginate(8);
     $page_size = setting('page_size');
     $tag = Tag::findBySlug($slug);
     $articles = \App\Article::with('tags', 'category')->whereHas('tags', function ($query) use($slug) {
         $query->whereSlug($slug);
     })->latest()->paginate($page_size);
     return view('home.tags.show', compact('articles', 'tag'));
 }
开发者ID:kpaxer,项目名称:laravel-blog,代码行数:17,代码来源:TagsController.php

示例13: index

 /**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $articles = Article::with('author')->orderBy('position', 'DESC')->orderBy('created_at', 'DESC')->limit(4)->get();
     //		TODO: abstract to model
     $sliders = Photo::join('photo_albums', 'photo_albums.id', '=', 'photos.photo_album_id')->where('photos.slider', 1)->orderBy('photos.position', 'DESC')->orderBy('photos.created_at', 'DESC')->select('photos.filename', 'photos.name', 'photos.description', 'photo_albums.folder_id')->get();
     $photoAlbums = PhotoAlbum::select(array('photo_albums.id', 'photo_albums.name', 'photo_albums.description', 'photo_albums.folder_id', DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id LIMIT 1) AS album_image'), DB::raw('(select filename from ' . DB::getTablePrefix() . 'photos WHERE ' . DB::getTablePrefix() . 'photos.photo_album_id=' . DB::getTablePrefix() . 'photo_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     $videoAlbums = VideoAlbum::select(array('video_albums.id', 'video_albums.name', 'video_albums.description', 'video_albums.folder_id', DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE album_cover=TRUE and ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id LIMIT 1) AS album_image'), DB::raw('(select youtube from ' . DB::getTablePrefix() . 'videos WHERE ' . DB::getTablePrefix() . 'videos.video_album_id=' . DB::getTablePrefix() . 'video_albums.id ORDER BY position ASC, id ASC LIMIT 1) AS album_image_first')))->limit(8)->get();
     return view('pages.home', compact('articles', 'sliders', 'videoAlbums', 'photoAlbums'));
     //return view('pages.welcome');
 }
开发者ID:nvven,项目名称:project,代码行数:15,代码来源:HomeController.php

示例14: index

 public function index()
 {
     $article = Article::with('users')->limit(2)->orderBy('updated_at', 'desc')->get();
     $app = Application::with('users')->paginate(6);
     $ArticleCategory = ArticleCategory::all();
     $AppCategory = AppCategory::all();
     $test = AppCategory::with('applications')->where('name', '=', 'communication')->get();
     dd($test);
     return view('homepage.welcome', compact('article', 'app', 'ArticleCategory', 'AppCategory'));
 }
开发者ID:novanabs,项目名称:portofolio-apps,代码行数:10,代码来源:WelcomeController.php

示例15: share_index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function share_index($page = '')
 {
     if (Input::get('class')) {
         $lifes = Article::with('cla')->orderBy('created_at', 'DESC')->where('classify', (int) Input::get('class'))->paginate(10)->setPath('share');
     } else {
         $classify = Classify::where('pid', '=', '2')->lists('id');
         $lifes = Article::with('cla')->orderBy('created_at', 'DESC')->whereIn('classify', $classify)->paginate(10)->setPath('share');
     }
     return view('home.life')->withLifes($lifes);
 }
开发者ID:todayqq,项目名称:TodayBlog,代码行数:15,代码来源:LifeController.php


注:本文中的app\Article::with方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。