本文整理匯總了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]);
}