本文整理匯總了PHP中app\models\Group::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Group::validate方法的具體用法?PHP Group::validate怎麽用?PHP Group::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Group
的用法示例。
在下文中一共展示了Group::validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: postGroup
public function postGroup($id = null)
{
if (Input::has('id')) {
$group = Group::find(Input::get('id'));
if (!$group->isGroupOwner(Auth::user()->id)) {
return Response::json($this->growlMessage('You cannot modify a group you do not own.', 'error'));
}
$message = "Your group has been updated!";
} else {
$group = new Group();
$group->status = Group::STATUS_PENDING;
$message = "Your group has been created! It must be approved before you can invite others to join or create documents.";
}
$postData = array('name', 'display_name', 'address1', 'address2', 'city', 'state', 'postal_code', 'phone_number');
foreach ($postData as $field) {
$group->{$field} = Input::get($field);
}
if ($group->validate()) {
$group->save();
$group->addMember(Auth::user()->id, Group::ROLE_OWNER);
if ($group->status === Group::STATUS_PENDING) {
Event::fire(MadisonEvent::VERIFY_REQUEST_GROUP, $group);
}
return Response::json($this->growlMessage($message, 'success'));
} else {
return Response::json($this->growlMessage($group->getErrors()->all(), 'error'), 400);
}
}