/**
  * 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
0
 /**
  * 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
0
 /**
  * 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));
 }
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
0
<?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
0
 public function save(Resource $resource)
 {
     return $resource->save();
 }
예제 #7
0
     $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()) {