public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Restaurant::create(['name' => $faker->company, 'latitude' => $faker->randomFloat(5, -90, 90), 'longitude' => $faker->randomFloat(5, -180, 180)]);
     }
 }
     $max_capacity += intval($_POST['numberCapacity2']) * 2;
 }
 if (isset($_POST['hasCapacity4']) && $_POST['hasCapacity4'] === 'true') {
     $max_capacity += intval($_POST['numberCapacity4']) * 4;
 }
 if (isset($_POST['hasCapacity6']) && $_POST['hasCapacity6'] === 'true') {
     $max_capacity += intval($_POST['numberCapacity6']) * 6;
 }
 if (isset($_POST['hasCapacity8']) && $_POST['hasCapacity8'] === 'true') {
     $max_capacity += intval($_POST['numberCapacity8']) * 8;
 }
 // echo $max_capacity;
 $fields = array('name' => $name, 'address' => $address, 'city' => $city, 'state' => $state, 'zipcode' => $zipcode, 'phone_number' => $phone_number, 'cuisine_type' => $cuisine_type, 'description' => $description, 'max_capacity' => $max_capacity, 'rating' => $rating, 'approved' => 0, 'owner_user_id' => $owner_user_id);
 try {
     $newRestaurant = new Restaurant();
     $newRestaurant->create($fields);
     $success = true;
     $message = 'Restaurant sign up complete!';
     $restaurant_id = $newRestaurant->get_restaurant_id();
     // after insert restaurant info without errors
     // add image to images table
     require_once '../lib/helper.functions.php';
     $image_client_path = $_FILES['file']['name'];
     $image_mime = $_FILES['file']['type'];
     $image_size = $_FILES['file']['size'];
     $image_error = $_FILES['file']['error'];
     $image_original_path = 'upload/original/';
     $image_medium_path = 'upload/medium/';
     $image_small_path = 'upload/small/';
     $tmp_file = $_FILES["file"]["tmp_name"];
     if ($image_error > 0) {
Пример #3
0
 /**
  * testBehaviorValidateMethods method
  *
  * @return void
  */
 public function testBehaviorValidateMethods()
 {
     $Apple = new Restaurant();
     $Apple->Behaviors->load('Test');
     $Apple->validate['color'] = 'validateField';
     $result = $Apple->save(array('name' => 'Genetically Modified Apple', 'color' => 'Orange'));
     $this->assertEquals(array('name', 'color', 'modified', 'created', 'id'), array_keys($result['Apple']));
     $Apple->create();
     $result = $Apple->save(array('name' => 'Regular Apple', 'color' => 'Red'));
     $this->assertFalse($result);
 }