本文整理汇总了PHP中model::create方法的典型用法代码示例。如果您正苦于以下问题:PHP model::create方法的具体用法?PHP model::create怎么用?PHP model::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::create方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$request = Request::instance();
$content = $request->getContent();
$inputs = json_decode($content, true);
try {
$contact = $this->model->create($inputs);
if ($contact) {
return Response::json(array('insertedId' => $contact->id), 201);
}
} catch (Exception $e) {
return Response::json($e->getMessage(), 400);
}
}
示例2: recycle
/**
* Look for a dam:trash, and move element inside. create dam:trash at root if not found
* @param {Integer} $id of the node to recycle
* @return {Boolean} true on success, false otherwise
*/
static function recycle($id)
{
$trashcan = model::searchKey('id', 'dam:trash');
$trashcan = $trashcan[0];
if (!$trashcan) {
$trashcan = model::create(array('#parent' => '0', 'id' => 'dam:trash', 'name' => 'dam:trash', 'type' => 'folder'));
}
return model::move($id, $trashcan);
}
示例3: postCreate
public function postCreate(ContactFormRequest $request)
{
$model = $this->model->create($request->all());
if ($model) {
Notification::container()->success(trans('contacts::global.create.success'));
return Redirect::to('/admin/contacts/' . $model->id . '/edit');
} else {
Notification::container()->error(trans('contacts::global.create.error'));
return Redirect::to('/admin/contacts/create');
}
}
示例4: copy
/**
* Copy a node - not recursive
* @param {Integer} $id node index
* @param {Integer} $tgt parent index for new node or false for same location
* @return {Boolean} true on success, false otherwise
*/
static function copy($id)
{
// copy node
$newid = model::create(model::keys($id));
if (!$newid) {
return false;
}
// copy tags
$query = "SELECT name FROM tag WHERE node_id='{$id}';";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
model::tag($newid, $row["name"]);
}
return $newid;
}
示例5: version_increment2
/**
* @deprecated (STUDIO100 versioning)
* Increment the asset after a successful commit. The path is incremented too. Not backup needed
* @param {Integer} asset node index
* @param {String} user message for the new version
*/
static function version_increment2($id, $message)
{
$file = model::getKey($id, 'file');
if (!$file) {
return false;
}
return model::create(array('#parent' => $id, 'file' => dirname(dirname($file)) . '/' . $version . '/' . basename($file), 'text' => $message, 'time' => time(), 'type' => 'asset', 'user' => getUser(), 'version' => model::getKey($id, "version") ? str_pad(model::getKey($id, "version") + 1, 3, '0', STR_PAD_LEFT) : "001"));
/*
$file = model::getKey( $id, 'file' );
if( !$file ) return false;
$new_id = model::createNode( $id, "asset" );
if( !$new_id ) return false;
$version = model::getKey( $id, "version" ) ? str_pad( model::getKey( $id, "version" ) + 1, 3, '0', STR_PAD_LEFT ) : "001";
model::setKey( $new_id, "file", dirname( dirname( $file ) ) . '/' . $version . '/' . basename( $file ) );
model::setKey( $new_id, "text", $message );
model::setKey( $new_id, "time", time() );
model::setKey( $new_id, "user", getUser() );
model::setKey( $new_id, "version", $version );
model::setKey( $id, "file", model::getKey( $new_id, "file" ) );
model::setKey( $id, "time", model::getKey( $new_id, "time" ) );
model::setKey( $id, "version", model::getKey( $new_id, "version" ) );
return $new_id;
*/
}
示例6: header
exit;
}
header('Content-type: application/json');
$ret = false;
switch (arg("cmd")) {
/* SCRUD operations */
case "search":
echo json_encode(model::search(json_decode(arg("keys")), arg("sortby"), arg("order"), arg("limit")));
break;
case "create":
if (is_null(arg('keys'))) {
header("HTTP/1.1: 400 Bad Request");
echo "Bad command";
exit;
}
$id = model::create(json_decode(arg("keys")));
if (!$id) {
header("HTTP/1.1: 409 Conflict");
echo "create Error, please change your values";
exit;
}
echo json_encode(model_json::node($id, 1, $NODE_TAG | $NODE_PRM));
break;
case "read":
if (is_null(arg('id'))) {
header('HTTP/1.1: 400 Bad Request');
exit;
}
if (strpos(arg("id"), ",") === false) {
$ret = model_json::node(arg("id"), 1, $NODE_TAG | $NODE_PRM);
if (!$ret) {
示例7: create
function create($array)
{
// encode password before creating
$array['f_user_password'] = $GLOBALS['auth']->encoder->Encrypt_Text($array['f_user_password']);
return parent::create($array);
}
示例8: session_start
session_start();
include_once "lib/http_service.php";
include_once "lib/model_json.php";
damas_service::init_http();
damas_service::accessGranted();
header('Content-type: application/json');
$ret = false;
//CRUD Operations
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
damas_service::allowed("model::create");
if (empty($_POST)) {
header("HTTP/1.1: 400 Bad Request");
echo "Bad command";
exit;
}
$id = model::create($_POST);
if (!$id) {
header("HTTP/1.1: 409 Conflict");
echo "create Error, please change your values";
exit;
}
echo json_encode(model_json::node($id, 1, $NODE_TAG | $NODE_PRM));
damas_service::log_event();
exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
damas_service::allowed("model::read");
if (empty($_GET) || $_GET['id'] == '') {
header('HTTP/1.1: 400 Bad Request');
echo "Bad command";
exit;
示例9: arg
$msg .= model::getKey($id, 'file') . " increment failed. ";
continue;
}
model::setKey($id, 'bytes', $file['size']);
break;
}
//if( !assets::asset_upload( $asset, $file['tmp_name'], "new version uploaded" ) )
//{
// header("HTTP/1.1: 304 Not Modified Asset Not updated");
// echo json_encode('The file upload failed, the asset was not updated');
// exit;
//}
} else {
// creation
if (move_uploaded_file($file['tmp_name'], $assetsLCL . $path)) {
model::create(array('#parent' => arg('id'), 'file' => $path, 'text' => arg('message'), 'user' => getUser(), 'time' => time(), 'type' => 'asset', 'bytes' => $file['size'], 'version' => 1));
} else {
$error_detected = true;
$msg .= $path . " move_uploaded_file failed (enough space?). ";
continue;
}
}
if ($error_detected) {
header("HTTP/1.1: 409 Conflict");
echo $msg . 'No change made.';
exit;
}
break;
case "uploadV1":
// DEPRECATED
if (model::getKey(arg('id'), 'lock') && model::getKey(arg('id'), 'lock') != getUser()) {
示例10: Create
/**
* @param array $data
* @return mixed
*/
public function Create(array $data)
{
return $this->_model->create($data);
}
示例11: create
/**
* create
*
* create a new record
*
* @param array $attributes
*
* @return mixed
*/
public function create(array $attributes)
{
return $this->model->create($attributes);
}