本文整理汇总了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');
}
示例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'));
}
示例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'));
}
示例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);
}
示例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'));
}
示例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'));
}
示例7: get
public function get($id)
{
$article = Article::with('tags')->find($id);
if (!$article) {
return response()->json(null, 404);
}
return response()->json($article);
}
示例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();
}));
});
}
示例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'));
}
示例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'));
}
示例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'));
}
示例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'));
}
示例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');
}
示例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'));
}
示例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);
}