/**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $validation = Validator::make($input, Property::$rules);
     if ($validation->passes()) {
         $this->property->create($input);
         return Redirect::route('admin.properties.index');
     }
     return Redirect::route('admin.properties.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
 }
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Property::create([]);
     }
 }
 /**
  * Store a newly created resource in storage.
  * POST /properties
  *
  * @return Response
  */
 public function store()
 {
     $property = Property::create(Input::all());
     if ($property) {
         return ['status' => true, 'property' => $property];
     } else {
         return ['status' => false];
     }
 }
 /**
  * Store a newly created property in storage.
  *
  * @return Response
  */
 public function postStore()
 {
     $validator = Validator::make($data = Input::all(), Property::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     Property::create($data);
     return Redirect::action('PropertiesController@getIndex');
 }
Beispiel #5
0
 public function doInsertProperty($contactID, $viewcountID)
 {
     $property = Property::create();
     $property->Latitude = '-37.786428';
     $property->Longitude = '175.278766';
     $property->Address = '3 Defoe Avenue, Hillcrest Hamilton, New Zealand';
     $property->LandArea = 615;
     $property->FloorArea = 95;
     $property->PropertyIDNumber = 'LH11070';
     $property->Status = 0;
     $property->BedRoomCount = 3;
     $property->LivingRoomCount = 1;
     $property->BathRoomCount = 1;
     $property->GarageCount = 1;
     $property->ListedDate = '2015-10-15';
     $property->ContactPersonID = $contactID;
     $property->ViewCountID = $viewcountID;
     $property->MapsPageID = $this->ID;
     $property->write();
 }
Beispiel #6
0
 /**
  * Using the setter method you can add properties or subcomponents
  *
  * You can either pass a Component, Property
  * object, or a string to automatically create a Property.
  *
  * If the item already exists, it will be removed. If you want to add
  * a new item with the same name, always use the add() method.
  *
  * @param string $name
  * @param mixed $value
  * @return void
  */
 public function __set($name, $value)
 {
     $matches = $this->select($name);
     $overWrite = count($matches) ? key($matches) : null;
     if ($value instanceof Component || $value instanceof Property) {
         $value->parent = $this;
         if (!is_null($overWrite)) {
             $this->children[$overWrite] = $value;
         } else {
             $this->children[] = $value;
         }
     } elseif (is_scalar($value)) {
         $property = Property::create($name, $value);
         $property->parent = $this;
         if (!is_null($overWrite)) {
             $this->children[$overWrite] = $property;
         } else {
             $this->children[] = $property;
         }
     } else {
         throw new \InvalidArgumentException('You must pass a \\Sabre\\VObject\\Component, \\Sabre\\VObject\\Property or scalar type');
     }
 }
 /**
  * Parses the input data and returns a correct VFREEBUSY object, wrapped in
  * a VCALENDAR.
  *
  * @return Component
  */
 public function getResult()
 {
     $busyTimes = array();
     foreach ($this->objects as $object) {
         foreach ($object->getBaseComponents() as $component) {
             switch ($component->name) {
                 case 'VEVENT':
                     $FBTYPE = 'BUSY';
                     if (isset($component->TRANSP) && strtoupper($component->TRANSP) === 'TRANSPARENT') {
                         break;
                     }
                     if (isset($component->STATUS)) {
                         $status = strtoupper($component->STATUS);
                         if ($status === 'CANCELLED') {
                             break;
                         }
                         if ($status === 'TENTATIVE') {
                             $FBTYPE = 'BUSY-TENTATIVE';
                         }
                     }
                     $times = array();
                     if ($component->RRULE) {
                         $iterator = new RecurrenceIterator($object, (string) $component->uid);
                         if ($this->start) {
                             $iterator->fastForward($this->start);
                         }
                         $maxRecurrences = 200;
                         while ($iterator->valid() && --$maxRecurrences) {
                             $startTime = $iterator->getDTStart();
                             if ($this->end && $startTime > $this->end) {
                                 break;
                             }
                             $times[] = array($iterator->getDTStart(), $iterator->getDTEnd());
                             $iterator->next();
                         }
                     } else {
                         $startTime = $component->DTSTART->getDateTime();
                         if ($this->end && $startTime > $this->end) {
                             break;
                         }
                         $endTime = null;
                         if (isset($component->DTEND)) {
                             $endTime = $component->DTEND->getDateTime();
                         } elseif (isset($component->DURATION)) {
                             $duration = DateTimeParser::parseDuration((string) $component->DURATION);
                             $endTime = clone $startTime;
                             $endTime->add($duration);
                         } elseif ($component->DTSTART->getDateType() === Property\DateTime::DATE) {
                             $endTime = clone $startTime;
                             $endTime->modify('+1 day');
                         } else {
                             // The event had no duration (0 seconds)
                             break;
                         }
                         $times[] = array($startTime, $endTime);
                     }
                     foreach ($times as $time) {
                         if ($this->end && $time[0] > $this->end) {
                             break;
                         }
                         if ($this->start && $time[1] < $this->start) {
                             break;
                         }
                         $busyTimes[] = array($time[0], $time[1], $FBTYPE);
                     }
                     break;
                 case 'VFREEBUSY':
                     foreach ($component->FREEBUSY as $freebusy) {
                         $fbType = isset($freebusy['FBTYPE']) ? strtoupper($freebusy['FBTYPE']) : 'BUSY';
                         // Skipping intervals marked as 'free'
                         if ($fbType === 'FREE') {
                             continue;
                         }
                         $values = explode(',', $freebusy);
                         foreach ($values as $value) {
                             list($startTime, $endTime) = explode('/', $value);
                             $startTime = DateTimeParser::parseDateTime($startTime);
                             if (substr($endTime, 0, 1) === 'P' || substr($endTime, 0, 2) === '-P') {
                                 $duration = DateTimeParser::parseDuration($endTime);
                                 $endTime = clone $startTime;
                                 $endTime->add($duration);
                             } else {
                                 $endTime = DateTimeParser::parseDateTime($endTime);
                             }
                             if ($this->start && $this->start > $endTime) {
                                 continue;
                             }
                             if ($this->end && $this->end < $startTime) {
                                 continue;
                             }
                             $busyTimes[] = array($startTime, $endTime, $fbType);
                         }
                     }
                     break;
             }
         }
     }
     if ($this->baseObject) {
         $calendar = $this->baseObject;
     } else {
         $calendar = Component::create('VCALENDAR');
         $calendar->version = '2.0';
         $calendar->prodid = '-//Sabre//Sabre VObject ' . Version::VERSION . '//EN';
         $calendar->calscale = 'GREGORIAN';
     }
     $vfreebusy = Component::create('VFREEBUSY');
     $calendar->add($vfreebusy);
     if ($this->start) {
         $dtstart = Property::create('DTSTART');
         $dtstart->setDateTime($this->start, Property\DateTime::UTC);
         $vfreebusy->add($dtstart);
     }
     if ($this->end) {
         $dtend = Property::create('DTEND');
         $dtend->setDateTime($this->end, Property\DateTime::UTC);
         $vfreebusy->add($dtend);
     }
     $dtstamp = Property::create('DTSTAMP');
     $dtstamp->setDateTime(new \DateTime('now'), Property\DateTime::UTC);
     $vfreebusy->add($dtstamp);
     foreach ($busyTimes as $busyTime) {
         $busyTime[0]->setTimeZone(new \DateTimeZone('UTC'));
         $busyTime[1]->setTimeZone(new \DateTimeZone('UTC'));
         $prop = Property::create('FREEBUSY', $busyTime[0]->format('Ymd\\THis\\Z') . '/' . $busyTime[1]->format('Ymd\\THis\\Z'));
         $prop['FBTYPE'] = $busyTime[2];
         $vfreebusy->add($prop);
     }
     return $calendar;
 }
Beispiel #8
0
 public function test_associated_uniqueness()
 {
     $Property = new Property();
     $PropertyType = new PropertyType();
     $this->assertTrue($RanchoMaria =& $Property->create(array('description' => 'Rancho Maria')));
     $this->assertTrue($Rancho =& $PropertyType->create(array('description' => 'Rancho')));
     $Rancho->property->load();
     $this->assertEqual($Rancho->property->count(), 0);
     $Rancho->property->add($RanchoMaria);
     $this->assertEqual($Rancho->property->count(), 1);
     $this->assertTrue($RanchoMaria =& $Property->findFirstBy('description', 'Rancho Maria'));
     $this->assertTrue($Rancho =& $PropertyType->findFirstBy('description', 'Rancho', array('include' => 'properties')));
     $Rancho->property->add($RanchoMaria);
     $this->assertEqual($Rancho->property->count(), 1);
     $Rancho->set('description', 'Rancho Type');
     $this->assertTrue($Rancho->save());
     $this->assertTrue($Rancho =& $PropertyType->findFirstBy('description', 'Rancho Type', array('include' => 'properties')));
     $this->assertEqual($Rancho->property->count(), 1);
 }
Beispiel #9
0
 /**
  * Factory method for creating new properties
  *
  * This method automatically searches for the correct property class, based
  * on its name.
  *
  * You can specify the parameters either in key=>value syntax, in which case
  * parameters will automatically be created, or you can just pass a list of
  * Parameter objects.
  *
  * @param string $name
  * @param mixed $value
  * @param array $parameters
  * @return Property
  */
 public function createProperty($name, $value = null, array $parameters = array())
 {
     return Property::create($name, $value, $parameters);
 }
Beispiel #10
0
 /**
  * Reads and parses a single line.
  *
  * This method receives the full array of lines. The array pointer is used
  * to traverse.
  *
  * This method returns null if an invalid line was encountered, and the
  * IGNORE_INVALID_LINES option was turned on.
  *
  * @param array $lines
  * @param int $options See the OPTIONS constants.
  * @return Node
  */
 private static function readLine(&$lines, $options = 0)
 {
     $line = current($lines);
     $lineNr = key($lines);
     next($lines);
     // Components
     if (strtoupper(substr($line, 0, 6)) === "BEGIN:") {
         $componentName = strtoupper(substr($line, 6));
         $obj = Component::create($componentName);
         $nextLine = current($lines);
         while (strtoupper(substr($nextLine, 0, 4)) !== "END:") {
             $parsedLine = self::readLine($lines, $options);
             $nextLine = current($lines);
             if (is_null($parsedLine)) {
                 continue;
             }
             $obj->add($parsedLine);
             if ($nextLine === false) {
                 throw new ParseException('Invalid VObject. Document ended prematurely.');
             }
         }
         // Checking component name of the 'END:' line.
         if (substr($nextLine, 4) !== $obj->name) {
             throw new ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"');
         }
         next($lines);
         return $obj;
     }
     // Properties
     //$result = preg_match('/(?P<name>[A-Z0-9-]+)(?:;(?P<parameters>^(?<!:):))(.*)$/',$line,$matches);
     if ($options & self::OPTION_FORGIVING) {
         $token = '[A-Z0-9-\\._]+';
     } else {
         $token = '[A-Z0-9-\\.]+';
     }
     $parameters = "(?:;(?P<parameters>([^:^\"]|\"([^\"]*)\")*))?";
     $regex = "/^(?P<name>{$token}){$parameters}:(?P<value>.*)\$/i";
     $result = preg_match($regex, $line, $matches);
     if (!$result) {
         if ($options & self::OPTION_IGNORE_INVALID_LINES) {
             return null;
         } else {
             throw new ParseException('Invalid VObject, line ' . ($lineNr + 1) . ' did not follow the icalendar/vcard format');
         }
     }
     $propertyName = strtoupper($matches['name']);
     $propertyValue = preg_replace_callback('#(\\\\(\\\\|N|n))#', function ($matches) {
         if ($matches[2] === 'n' || $matches[2] === 'N') {
             return "\n";
         } else {
             return $matches[2];
         }
     }, $matches['value']);
     $obj = Property::create($propertyName, $propertyValue);
     if ($matches['parameters']) {
         foreach (self::readParameters($matches['parameters']) as $param) {
             $obj->add($param);
         }
     }
     return $obj;
 }
 function testCreateParams()
 {
     $property = Property::create('X-PROP', 'value', array('param1' => 'value1', 'param2' => array('value2', 'value3')));
     $this->assertEquals(1, count($property['PARAM1']));
     $this->assertEquals(2, count($property['PARAM2']));
 }
Beispiel #12
0
 function testValidateBadPropertyName()
 {
     $property = Property::create("X_*&PROP*", "Bla");
     $result = $property->validate(Property::REPAIR);
     $this->assertEquals($result[0]['message'], 'The propertyname: X_*&PROP* contains invalid characters. Only A-Z, 0-9 and - are allowed');
     $this->assertEquals('X-PROP', $property->name);
 }
Beispiel #13
0
 /**
  * @param $object
  * @param $filename
  * @param bool $multiple
  * @return static
  */
 static function analyzeJSON($object, $className)
 {
     $normalizedClassName = normalizeClassName($className);
     if (is_object($object) == false && is_array($object) == false) {
         throw new \Exception("Neither object or array in class {$className}");
     }
     //Assume arrays only have one type of content.
     if (is_array($object)) {
         $instance = self::createClass($className, $normalizedClassName);
         foreach ($object as $key => $valueElement) {
             $name = $className . "_child";
             if (is_object($valueElement) || is_array($valueElement)) {
                 $childInstance = AnalyzedClass::analyzeJSON($valueElement, $name);
                 $childInstance->multiple = true;
                 $instance->properties[] = $childInstance;
             } else {
                 $instance->multiple = true;
             }
             return $instance;
         }
         $instance->multiple = true;
         return $instance;
     }
     $instance = self::createClass($className, $normalizedClassName);
     foreach ($object as $name => $value) {
         if (is_object($value)) {
             $childInstance = AnalyzedClass::analyzeJSON($value, $name, false);
             $instance->properties[] = $childInstance;
         } else {
             if (is_array($value)) {
                 $childInstance = AnalyzedClass::analyzeJSON($value, $name, false);
                 $instance->properties[] = $childInstance;
                 //$childInstance = AnalyzedClass::analyzeJSON($value, $name);
                 //                foreach ($value as $key => $valueElement) {
                 //                    if (is_object($valueElement) ||
                 //                        (is_array($valueElement))) {// && is_numeric_array($valueElement) == false)) {
                 //                        $childInstance = AnalyzedClass::analyzeJSON($valueElement, $name, true);
                 //                        $instance->properties[] = $childInstance;
                 //                        break;
                 //                    }
                 //                    else {
                 //                        if (is_object($valueElement) || is_array($valueElement)) {
                 //                            $childInstance = AnalyzedClass::analyzeJSON($valueElement, $name."_child", true);
                 //                            $instance->properties[] = $childInstance;
                 //                        }
                 //                        else {
                 //                            $instance->properties[] = Property::create($key, true);
                 //                        }
                 //                    }
                 //                }
             } else {
                 $instance->properties[] = Property::create($name, false);
             }
         }
     }
     $sortByPropertyName = function (Property $a, Property $b) {
         return strcasecmp($a->name, $b->name);
     };
     usort($instance->properties, $sortByPropertyName);
     return $instance;
 }
Beispiel #14
0
 public function addproperty()
 {
     if (!Owner::isAuthenticated()) {
         $this->redirect('/');
     } else {
         if ($_SERVER['REQUEST_METHOD'] === 'POST') {
             $property = Property::create(['address' => $_POST['address'], 'payment_schedule' => $_POST['payment_schedule'], 'rent_amount' => $_POST['rent_amount'], 'owner_id' => $_SESSION['user']->id, 'photo' => DUMMY_IMAGE]);
             Flash::set('message', 'You added a new property!');
             $this->redirect('/propertyowner/manage');
         } else {
             $this->view('owner/addpropertyform');
         }
     }
 }