本文整理汇总了PHP中Restaurant::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::create方法的具体用法?PHP Restaurant::create怎么用?PHP Restaurant::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
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)]);
}
}
示例2: intval
$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: testBehaviorValidateMethods
/**
* 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);
}