本文整理汇总了PHP中Data::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::create方法的具体用法?PHP Data::create怎么用?PHP Data::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data
的用法示例。
在下文中一共展示了Data::create方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAction
public function addAction()
{
$form = new DataForm();
if ($form->isPosted()) {
if ($form->isValidForAdd()) {
$id = Data::create(["name" => Input::get("name"), "description" => Input::get("description"), "mobile" => Input::get("mobile"), "email" => Input::get("email"), "address" => Input::get("address"), "web" => Input::get("web"), "ranking" => 50])->id;
$this->associateUser(Auth::user()->id, $id);
return Redirect::route($this->routeAdd);
}
return Redirect::route($this->routeAdd)->withInput(["errors" => $form->getErrors()]);
//die(var_dump($form->getErrors()));
return Redirect::route($this->routeAdd)->withErrors($form->getErrors())->withInput();
}
return View::make($this->routeAdd, ["form" => $form, "HeaderTitle" => trans('addData.title')]);
}
示例2: addAction
public function addAction()
{
$form = new ProductoForm();
if ($form->isPosted()) {
if ($form->isValidForAdd()) {
$ID_INVENTARIO = Data::create(["ID_INVENTARIO" => Input::get("ID_INVENTARIO"), "ID_VENTA" => Input::get("ID_VENTA"), "ID_PRODUCTO" => Input::get("ID_PRODUCTO"), "ID_RUTA" => Input::get("ID_RUTA"), "NOMBRE_PRODUCTO" => Input::get("NOMBRE_PRODUCTO"), "DISPONIBLE" => 1])->ID_INVENTARIO;
//$this->associateUser(Auth::user()->id,$id);
return Redirect::route($this->routeAdd);
}
return Redirect::route($this->routeAdd)->withInput(["errors" => $form->getErrors()]);
//die(var_dump($form->getErrors()));
return Redirect::route($this->routeAdd)->withErrors($form->getErrors())->withInput();
}
return View::make($this->routeAdd, ["form" => $form, "HeaderTitle" => trans('addData.title')]);
}
示例3:
<nav class="navbar navbar-full navbar-inverse">
<div class="navbar-brand center-block">
<h3>php :: mon </h3>
</div>
</nav>
<div class="container">
<?php
if ($_POST) {
$product->name = $_POST['name'];
$product->url = $_POST['url'];
$product->host = $_POST['host'];
if ($product->create()) {
?>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Success!</strong> <a href="index.php">View Data</a>.
</div>
<?php
} else {
?>
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
<strong>Fail!</strong></div>
<?php
}
}
?>
示例4: checkIntegrity
/**
* checkIntegrity
* --------------------------------------------------
* Checking a widget's overall integrity,
* setting state accordingly.
* --------------------------------------------------
*/
protected function checkIntegrity($commit = TRUE)
{
// Data integrity validation.
if ($this instanceof iDataWidget) {
// Exception variables.
$valid = TRUE;
$save = FALSE;
try {
$this->checkData();
} catch (MissingData $e) {
// Data object is not present but it should be.
$valid = FALSE;
$save = TRUE;
$data = Data::create(array('raw_value' => $this->createDataScheme()));
$this->data()->associate($data);
$data->save();
} catch (InvalidData $e) {
// Invalid data found in db, doing cleanup.
$valid = FALSE;
$save = TRUE;
$this->data->raw_value = $this->createDataScheme();
$this->data->save();
} catch (EmptyData $e) {
// Data not yet populated.
$valid = FALSE;
}
// Updating widget state accordingly.
if (!$valid && $this->state == 'active') {
$this->state = 'missing_data';
$save = TRUE;
} elseif ($valid && $this->state == 'missing_data') {
// Valid and was missing_data -> set to active.
$this->state = 'active';
$save = TRUE;
}
if ($save && $commit) {
$this->save();
}
}
}