本文整理汇总了PHP中app\News::with方法的典型用法代码示例。如果您正苦于以下问题:PHP News::with方法的具体用法?PHP News::with怎么用?PHP News::with使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\News
的用法示例。
在下文中一共展示了News::with方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$news = News::with('langs');
if (!$this->systemAdmin) {
$news->where('department_id', auth()->user()->department_id);
}
if (session('department_filter_id')) {
$news = $news->where('department_id', session('department_filter_id'));
}
$news = $news->sort()->get();
$this->loadLangs($news);
return view('admin.news.index', ['title' => trans('static.news'), 'url' => action('Admin\\NewsController@create'), 'news' => $news]);
}
示例2: edit
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$news = News::with('categories')->where('id', $id)->first();
return view('dashboard/edit_news')->with('categories', Category::get())->with("news", $news);
}
示例3: index
/**
* @return mixed
*/
public function index()
{
return view('news.index')->withAllnews($this->news->with('photo')->with('user')->latest()->paginate(10));
}