コード例 #1
0
 /**
  * Store a newly created resource in storage.
  * POST /area
  *
  * @return Response
  */
 public function store()
 {
     $V = Validator::make(Input::all(), ['name' => 'required|string']);
     if ($V->fails()) {
         return Response::json($V->messages()->all(), 400);
     }
     $name = Input::get('name');
     $Area = Area::where('name', '=', $name);
     if ($Area->count() > 0) {
         // already exists :/
         return Response::json($Area->toArray(), 409);
     }
     $NewArea = new Area();
     $NewArea->name = $name;
     $NewArea->save();
     return Response::json($NewArea->toArray(), 201);
 }
コード例 #2
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['FreeShipping'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['FreeShipping'][$this->getPrimaryKey()] = true;
     $keys = FreeShippingTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), $keys[2] => $this->getAmount());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aArea) {
             $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
コード例 #3
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['SocolissimoPrice'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['SocolissimoPrice'][$this->getPrimaryKey()] = true;
     $keys = SocolissimoPriceTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), $keys[2] => $this->getDeliveryModeId(), $keys[3] => $this->getWeightMax(), $keys[4] => $this->getPrice());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aArea) {
             $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aSocolissimoDeliveryMode) {
             $result['SocolissimoDeliveryMode'] = $this->aSocolissimoDeliveryMode->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
コード例 #4
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME,
  *                    TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM.
  *                    Defaults to TableMap::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['TntPriceWeight'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['TntPriceWeight'][$this->getPrimaryKey()] = true;
     $keys = TntPriceWeightTableMap::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAreaId(), $keys[2] => $this->getTntProductLabel(), $keys[3] => $this->getTntProductCode(), $keys[4] => $this->getWeight(), $keys[5] => $this->getPrice(), $keys[6] => $this->getPriceKgSup(), $keys[7] => $this->getCreatedAt(), $keys[8] => $this->getUpdatedAt());
     $virtualColumns = $this->virtualColumns;
     foreach ($virtualColumns as $key => $virtualColumn) {
         $result[$key] = $virtualColumn;
     }
     if ($includeForeignObjects) {
         if (null !== $this->aArea) {
             $result['Area'] = $this->aArea->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }