本文整理汇总了PHP中Resource::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Resource::save方法的具体用法?PHP Resource::save怎么用?PHP Resource::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resource
的用法示例。
在下文中一共展示了Resource::save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$validator = Resource::validate(Input::all());
if ($validator->fails()) {
return Redirect::to('resources/create')->withErrors($validator)->withInput(Input::all());
} else {
// store
$resource = new Resource();
$resource->name = Input::get('name');
$resource->description = Input::get('description');
$resource->url = Input::get('url');
$resource->hits = 0;
$resource->level = Input::get('level');
$resource->faculty = Input::get('faculty');
$deviceIds = Input::get('devices');
$tagIds = Input::get('tag_ids');
$resource->save();
if ($tagIds != '') {
$tagIds = explode(",", $tagIds);
$resource->tags()->attach($tagIds);
}
if ($deviceIds != '') {
foreach ($deviceIds as $device_type) {
$device = new Device(array("device_type" => $device_type));
$resource->devices()->save($device);
}
}
return Redirect::to('resources');
}
}
示例2: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Resource();
$model->attributes = $_POST;
$result = $model->save();
$this->sendAjaxResponse($model);
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new Resource();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['Resource'])) {
$model->attributes = $_POST['Resource'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->id));
}
}
$this->render('create', array('model' => $model));
}
示例4: postResource
function postResource($resourceId = 0)
{
global $app;
// INSERT Resource
$resource = new Resource();
$resource->param1 = 'hello';
$resource->param2 = 'world';
$resource->save();
if ($resource) {
$app->response->setStatus(200);
echo $resource->toJson();
} else {
$app->response->setStatus(400);
echo '{"error":{"text":"request failed"}}';
}
}
示例5: Resource
<?php
$resourceID = $_POST['resourceID'];
$resource = new Resource(new NamedArguments(array('primaryKey' => $resourceID)));
try {
$resource->save();
//first remove all payment records, then we'll add them back
$resource->removeResourcePayments();
$yearArray = array();
$yearArray = explode(':::', $_POST['years']);
$subStartArray = array();
$subStartArray = explode(':::', $_POST['subStarts']);
$subEndArray = array();
$subEndArray = explode(':::', $_POST['subEnds']);
$fundIDArray = array();
$fundIDArray = explode(':::', $_POST['fundIDs']);
$paymentAmountArray = array();
$paymentAmountArray = explode(':::', $_POST['paymentAmounts']);
$currencyCodeArray = array();
$currencyCodeArray = explode(':::', $_POST['currencyCodes']);
$orderTypeArray = array();
$orderTypeArray = explode(':::', $_POST['orderTypes']);
$costDetailsArray = array();
$costDetailsArray = explode(':::', $_POST['costDetails']);
$costNoteArray = array();
$costNoteArray = explode(':::', $_POST['costNotes']);
$invoiceArray = array();
$invoiceArray = explode(':::', $_POST['invoices']);
foreach ($orderTypeArray as $key => $value) {
if ($value && ($paymentAmountArray[$key] || $yearArray[$key] || $fundIDArray[$key] || $costNoteArray[$key])) {
$resourcePayment = new ResourcePayment();
示例6: save
public function save(Resource $resource)
{
return $resource->save();
}
示例7: count
$resources = $resourceObj->getResourceByIsbnOrISSN($deduping_values);
$resource = $resources[0];
}
// Do we have a parent resource to create?
if ($data[$_POST['parentResource']] && ($deduping_count == 0 || $deduping_count == 1)) {
// Search if such parent exists
$numberOfParents = count($resourceObj->getResourceByTitle($data[$_POST['parentResource']]));
$parentID = null;
if ($numberOfParents == 0) {
// If not, create parent
$parentResource = new Resource();
$parentResource->createLoginID = $loginID;
$parentResource->createDate = date('Y-m-d');
$parentResource->titleText = $data[$_POST['parentResource']];
$parentResource->statusID = 1;
$parentResource->save();
$parentID = $parentResource->resourceID;
$parentInserted++;
} elseif ($numberOfParents == 1) {
// Else, attach the resource to its parent.
$parentResource = $resourceObj->getResourceByTitle($data[$_POST['parentResource']]);
$parentID = $parentResource[0]->resourceID;
$parentAttached++;
}
if ($numberOfParents == 0 || $numberOfParents == 1) {
$resourceRelationship = new ResourceRelationship();
$resourceRelationship->resourceID = $resource->resourceID;
$resourceRelationship->relatedResourceID = $parentID;
$resourceRelationship->relationshipTypeID = '1';
//hardcoded because we're only allowing parent relationships
if (!$resourceRelationship->exists()) {