本文整理汇总了PHP中app\News::first方法的典型用法代码示例。如果您正苦于以下问题:PHP News::first方法的具体用法?PHP News::first怎么用?PHP News::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\News
的用法示例。
在下文中一共展示了News::first方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: comment
public function comment($slug)
{
$news2 = DB::table('news')->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news_categories.name as category', 'news.s_content', 'users.name as publisher', 'news.image', 'news.created_at', 'users.image as image2')->get();
$news = News::where('slug', '=', $slug)->leftJoin('users', 'news.publisher', '=', 'users.id')->leftJoin('news_categories', 'news.category', '=', 'news_categories.id')->select('news.title', 'news.slug', 'news.category', 'news.s_content', 'news.content', 'users.name as publisher', 'news.image', 'news.created_at')->get();
$com_id = News::first();
$comment = new Comment();
$comment->body = \Input::get('comment');
$comment->poster = \Input::get('author');
$comment->commentable_id = $com_id->id;
$com_id->comments()->save($comment);
return \Redirect::back()->with(['news' => $news, 'news2' => $news2]);
}