本文整理汇总了PHP中group::isInvalid方法的典型用法代码示例。如果您正苦于以下问题:PHP group::isInvalid方法的具体用法?PHP group::isInvalid怎么用?PHP group::isInvalid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group
的用法示例。
在下文中一共展示了group::isInvalid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
$group = new group();
$group->name = $request->input('name');
$group->body = $request->input('body');
$group->group_type = $request->input('group_type');
if ($request->get('address')) {
$group->address = $request->input('address');
if (!$group->geocode()) {
flash()->error(trans('messages.address_cannot_be_geocoded'));
} else {
flash()->info(trans('messages.ressource_geocoded_successfully'));
}
}
if ($group->isInvalid()) {
// Oops.
return redirect()->action('GroupController@create')->withErrors($group->getErrors())->withInput();
}
$group->save();
// handle cover
if ($request->hasFile('cover')) {
Storage::disk('local')->makeDirectory('groups/' . $group->id);
Image::make($request->file('cover'))->widen(800)->save(storage_path() . '/app/groups/' . $group->id . '/cover.jpg');
Image::make($request->file('cover'))->fit(300, 200)->save(storage_path() . '/app/groups/' . $group->id . '/thumbnail.jpg');
}
// make the current user a member of the group
$membership = \App\Membership::firstOrNew(['user_id' => $request->user()->id, 'group_id' => $group->id]);
$membership->notification_interval = 60 * 24;
// default to daily interval
$membership->membership = \App\Membership::MEMBER;
$membership->save();
return redirect()->action('MembershipController@settings', [$group->id]);
}