本文整理汇总了PHP中app\Group::discussions方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::discussions方法的具体用法?PHP Group::discussions怎么用?PHP Group::discussions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Group
的用法示例。
在下文中一共展示了Group::discussions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
*
* @param int $id
*
* @return Response
*/
public function show(Group $group)
{
if (Auth::check()) {
$discussions = $group->discussions()->with('user', 'userReadDiscussion')->orderBy('updated_at', 'desc')->limit(5)->get();
} else {
$discussions = $group->discussions()->with('user')->orderBy('updated_at', 'desc')->limit(5)->get();
}
$files = $group->files()->with('user')->orderBy('updated_at', 'desc')->limit(5)->get();
$actions = $group->actions()->where('start', '>=', Carbon::now())->orderBy('start', 'asc')->limit(10)->get();
return view('groups.show')->with('group', $group)->with('discussions', $discussions)->with('actions', $actions)->with('files', $files)->with('tab', 'home');
}
示例2: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request, Group $group)
{
$discussion = new Discussion();
$discussion->name = $request->input('name');
$discussion->body = $request->input('body');
$discussion->total_comments = 1;
// the discussion itself is already a comment
$discussion->user()->associate(Auth::user());
if (!$group->discussions()->save($discussion)) {
// Oops.
return redirect()->action('DiscussionController@create', $group->id)->withErrors($discussion->getErrors())->withInput();
}
flash()->info(trans('messages.ressource_created_successfully'));
return redirect()->action('DiscussionController@show', [$group->id, $discussion->id]);
}