本文整理汇总了PHP中Board::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Board::save方法的具体用法?PHP Board::save怎么用?PHP Board::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board::save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
//Validation
$rules = array('name' => 'required', 'message' => 'required');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to('/community/boards/create')->withInput()->withErrors($validator);
}
$board = new Board();
$board->name = Input::get('name');
$board->save();
$message = new Message();
$message->body = Input::get('message');
$message->board_id = $board->id;
$message->user_id = Auth::user()->id;
$message->save();
return Redirect::to('/community/boards/' . $board->id)->with('flash_message', 'Your board has been successfully created!')->with('alert_class', 'alert-success');
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Board;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['Board']))
{
$model->attributes=$_POST['Board'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}
$this->render('create',array(
'model'=>$model,
));
}
示例3: post_new
/**
* Create a board
*/
public function post_new()
{
$data = Input::get();
$rules = array('name' => 'required', 'description' => 'required', 'position' => 'integer');
$val = Validator::make($data, $rules);
if ($val->fails()) {
Session::flash('status', 'new-board-fail');
return Redirect::to('/')->with_input()->with_errors($val);
} else {
if (!isset($data['position'])) {
$data['position'] = 1;
}
// make the board
$board = new Board();
$board->name = $data['name'];
$board->description = $data['description'];
$board->position = $data['position'];
$board->save();
return Redirect::to('/');
}
}
示例4: StaffPermission
if ($BOARD['required_permission_id'] != null) {
$permission = new StaffPermission($db);
$permission = $permission->findOneByStaffPermissionId($BOARD['required_permission_id']);
if ($permission == null) {
$ERRORS[] = 'Invalid permission specified.';
} else {
$permission_id = $permission->getStaffPermissionId();
}
}
// end perm specified; check it
if (sizeof($ERRORS) > 0) {
draw_errors($ERRORS);
} else {
$board->setBoardName($BOARD['name']);
$board->setBoardDescr($BOARD['description']);
$board->setBoardLocked($BOARD['locked']);
$board->setNewsSource($BOARD['news_source']);
$board->setOrderBy($BOARD['order_by']);
$board->setRequiredPermissionId($permission_id);
$board->setBoardCategoryId($category->getBoardCategoryId());
$board->save();
$_SESSION['board_notice'] = "You have saved <strong>{$board->getBoardName()}</strong>.";
redirect('admin-boards');
}
// end no errors
break;
// end save
}
// end state switch
}
// end no errors
示例5: postAsk
public function postAsk()
{
try {
if (!isset($_POST)) {
throw new \Exception('Request error!');
}
$keys = array('name', 'sex', 'email', 'ask', 'content', 'code', 'isPrivate', 'user_id');
$values = array();
$bool = true;
foreach ($keys as $key) {
$values[$key] = \Arr::get($_POST, $key, false);
if ($values[$key] === false) {
$bool = false;
}
}
if (!$bool) {
throw new \Exception('Request error!');
}
if (!\Captcha::getInstance()->valid($values['code'])) {
throw new \Exception('驗証碼錯誤');
}
$values['isPrivate'] = $values['isPrivate'] == 'n' ? '0' : '1';
$b = new \Board();
$b->name = $values['name'];
$b->gender = $values['sex'];
$b->email = $values['email'];
$b->topic = $values['ask'];
$b->content = $values['content'];
$b->isPrivate = $values['isPrivate'];
$b->user_id = empty($values['user_id']) ? '' : (int) $values['user_id'];
$b->save();
return \Response::json(array('status' => 'ok'));
} catch (\Exception $e) {
return \Response::json(array('status' => 'error', 'message' => $e->getMessage()));
}
}