本文整理汇总了PHP中Restaurant::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::find方法的具体用法?PHP Restaurant::find怎么用?PHP Restaurant::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_find
function test_find()
{
//Arrange
$name = "American";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$restaurant_name = "VQ";
$phone = '5032277342';
$address = "1220 SW 1st Ave, Portland, OR 97204";
$website = "http://www.veritablequandary.com/";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($restaurant_name, $phone, $address, $website, $cuisine_id);
$test_restaurant->save();
$restaurant_name2 = "Hot Lips Pizza";
$phone2 = '5035952342';
$address2 = "721 NW 9th Ave #150, Portland, OR 97209";
$website2 = "http://hotlipspizza.com/";
$test_restaurant2 = new Restaurant($restaurant_name2, $phone2, $address2, $website2, $cuisine_id);
$test_restaurant2->save();
//Act
$result = Restaurant::find($test_restaurant->getId());
//Assert
$this->assertEquals($test_restaurant, $result);
}
示例2: suitableRestaurants
static function suitableRestaurants($option_ids)
{
// get array of all restaurant ids associated with any of the option ids (duplicates included)
$restaurant_ids_with_duplicates = array();
foreach ($option_ids as $option_id) {
$returned_restaurants = $GLOBALS['DB']->query("SELECT restaurants.* FROM options JOIN restaurants_options ON (options.id = restaurants_options.option_id) JOIN restaurants ON (restaurants_options.restaurant_id = restaurants.id) WHERE options.id = {$option_id};");
foreach ($returned_restaurants as $restaurant) {
array_push($restaurant_ids_with_duplicates, $restaurant['id']);
}
}
// count duplicates in $search_array_with_duplicates for values equal to the number of elements in the $option_ids array
$suitable_restaurants = array();
$options_count = count($option_ids);
$restaurant_id_duplicates = array_count_values($restaurant_ids_with_duplicates);
foreach ($restaurant_id_duplicates as $restaurant_id => $count) {
if ($options_count == $count) {
$restaurant = Restaurant::find($restaurant_id);
array_push($suitable_restaurants, $restaurant);
}
}
return $suitable_restaurants;
}
示例3: test_find
function test_find()
{
$name = "Asian";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$restaurant_name = "The Golden Duck";
$location = "898 SW 5th Ave, Portland, OR";
$description = "A Chill Asian experince";
$price = "\$\$";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($restaurant_name, $location, $description, $price, $cuisine_id);
$test_restaurant->save();
$restaurant_name2 = "The Red Dragon";
$location2 = "899 SW 5th Ave, Portland, OR";
$description2 = "A Intense Asian experince";
$price2 = "\$\$\$";
$cuisine_id2 = $test_cuisine->getId();
$test_restaurant2 = new Restaurant($restaurant_name2, $location2, $description2, $price2, $cuisine_id2);
$test_restaurant2->save();
$result = Restaurant::find($test_restaurant->getId());
$this->assertEquals($test_restaurant, $result);
}
示例4: test_find
function test_find()
{
//arrange
$name = "Taco Hell";
$id = null;
$test_restaurant = new Restaurant($name, $id);
$test_restaurant->save();
$name2 = "Burger Queen";
$test_restaurant2 = new Restaurant($name2, $id);
$test_restaurant2->save();
//act
$result = Restaurant::find($test_restaurant2->getId());
//assert
$this->assertEquals($test_restaurant2, $result);
}
示例5: test_find
function test_find()
{
//Arrange
$name = "Italian";
$id = null;
$test_cuisine = new Cuisine($name, $id);
$test_cuisine->save();
$name = "Piazza Italia";
$rating = 1;
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $id, $cuisine_id, $rating);
$test_restaurant->save();
$name2 = "Ristorante Roma";
$rating = 1;
$test_restaurant2 = new Restaurant($name2, $id, $cuisine_id, $rating);
$test_restaurant2->save();
//Act
$result = Restaurant::find($test_restaurant->getId());
//Assert
$this->assertEquals($test_restaurant, $result);
}
示例6: updateRestaurantInfo
public function updateRestaurantInfo()
{
$user = \Auth::user();
$id = $user->user_id;
$restaurant = \Restaurant::all();
foreach ($restaurant as $rest) {
$restaurant_name = $rest->restaurant_name;
$restaurant_street_1 = $rest->restaurant_street_1;
$restaurant_street_2 = $rest->restaurant_street_2;
$restaurant_phone = $rest->restaurant_phone;
$restaurant_email = $rest->restaurant_email;
$restaurant_id = $rest->restaurant_info_id;
}
\DB::beginTransaction();
try {
$statement = \Restaurant::find($restaurant_id);
$statement->restaurant_name = \Input::get('name');
$statement->restaurant_street_1 = \Input::get('address1');
$statement->restaurant_street_2 = \Input::get('address2');
$statement->restaurant_email = \Input::get('email');
$statement->restaurant_phone = \Input::get('phone');
$statement->user_id_fk = $id;
$statement->save();
} catch (ValidationException $e) {
DB::rollback();
throw $e;
}
\DB::commit();
return \Redirect::to('admin/account/edit/restaurant')->withRestaurantName($restaurant_name)->withRestaurantStreet_1($restaurant_street_1)->withRestaurantStreet_2($restaurant_street_2)->withRestaurantPhone($restaurant_phone)->withRestaurantEmail($restaurant_email)->with('message', '<p class="alert alert-dismissible alert-success alert-link">Saved!' . '</p>');
}
示例7: initialize
public function initialize($entity = null, $options = null)
{
$restaurant = new Select('restaurantid', Restaurant::find(), array('using' => array('id', 'name'), 'useEmpty' => TRUE, 'emptyText' => $this->di->get('translate')->_('Seleccione un Restaurante')));
$restaurant->setLabel('Pais');
$this->add($restaurant);
$name = new Text('name');
$name->setLabel('Name');
$this->add($name);
$active = new Select("active", array('Y' => $this->di->get('translate')->_('Yes'), 'N' => $this->di->get('translate')->_('No')), array('class' => 'form-control'));
$active->setLabel('active');
$this->add($active);
}
示例8: test_find
function test_find()
{
//Arrange
$restaurant_name = "Antoons";
$cuisine_type = 1;
$restaurant_phone = "4128675309";
$restaurant_address = "123 Atwood St";
$test_Restaurant = new Restaurant($restaurant_name, $cuisine_type, $restaurant_phone, $restaurant_address);
$test_Restaurant->save();
//Act
$result = Restaurant::find($test_Restaurant->getId());
//Assert
$this->assertEquals($test_Restaurant, $result);
}
示例9: addReview
public function addReview($data)
{
$this->user_id = $data['user_id'];
$this->restaurant_id = $data['restaurant_id'];
$this->content = $data['content'];
$this->rating = $data['rating'];
$this->created_at = $data['created_at'] = date('Y-m-d H:i:s');
$this->updated_at = $data['updated_at'] = date('Y-m-d H:i:s');
if ($this->create($data)) {
$restaurants = new Restaurant();
$restaurant = $restaurants->find('id', $this->restaurant_id);
$review_count = intval($restaurant['review_count']);
$rating = $review_count * intval($restaurant['rating']) + intval($this->rating);
$review_count += 1;
$rating /= $review_count;
$restaurants->update('id', $this->restaurant_id, ['rating' => $rating, 'review_count' => $review_count]);
$result['status'] = "success";
$result['success_text'] = "review added";
} else {
$result['status'] = "error";
$result['error_text'] = "review not added";
}
return json_encode($result);
}
示例10: test_find
function test_find()
{
//Arrange
$flavor = "Burgers";
$id = null;
$test_cuisine = new Cuisine($flavor, $id);
$test_cuisine->save();
$name = "Burger Bash";
$phone_number = "555-666-7777";
$address = "8020 Ground Chuck";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $phone_number, $address, $id, $cuisine_id);
$test_restaurant->save();
$name2 = "Pizza Party";
$phone_number2 = "555-666-7747";
$address2 = "1234 Pepperoni Lane";
$cuisine_id = $test_cuisine->getId();
$test_restaurant2 = new Restaurant($name2, $phone_number2, $address2, $id, $cuisine_id);
$test_restaurant2->save();
//Act
$result = Restaurant::find($test_restaurant->getId());
//Assert
$this->assertEquals($test_restaurant, $result);
}
示例11: test_find
function test_find()
{
//Arrange
$type = "french";
$id = null;
$test_cuisine = new Cuisine($type, $id);
$test_cuisine->save();
$name = "Petit Provence";
$phone = "555-555-5555";
$price = "\$\$";
$cuisine_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $phone, $price, $cuisine_id);
$test_restaurant->save();
$name2 = "Escargot";
$phone2 = "666-666-6666";
$price2 = "\$\$\$";
$test_restaurant2 = new Restaurant($name2, $phone2, $price2, $cuisine_id);
$test_restaurant2->save();
//Act
$result = Restaurant::find($test_restaurant->getId());
//Assert
$this->assertEquals($test_restaurant, $result);
}
示例12: test_find
function test_find()
{
//Arrange
$restaurant_name = "Joes Burgers";
$restaurant_name2 = "McDonalds";
$test_Restaurant = new Restaurant($restaurant_name);
$test_Restaurant->save();
$test_Restaurant2 = new Restaurant($restaurant_name2);
$test_Restaurant2->save();
//Act
$result = Restaurant::find($test_Restaurant->getId());
//Assert
$this->assertEquals($test_Restaurant, $result);
}
示例13: test_find
function test_find()
{
//Arrange
$name = "Drinks";
$id = null;
$test_Cuisine = new Cuisine($name, $id);
$test_Cuisine->save();
$restaurant = "Aalto";
$address = "123 Belmont";
$phone = "123-456-7890";
$cuisine_id = $test_Cuisine->getId();
$test_restaurant = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
$test_restaurant->save();
$restaurant2 = "HobNob";
$address2 = "999 somewhere";
$phone2 = "234-555-5555";
$cuisine_id2 = $test_Cuisine->getId();
$test_restaurant2 = new Restaurant($restaurant, $address, $phone, $cuisine_id, $id);
$test_restaurant2->save();
//Act
$result = Restaurant::find($test_restaurant->getId());
//Assert
$this->assertEquals($test_restaurant, $result);
}
示例14: header
session_start();
if (empty($_POST)) {
header('Location: index.php');
} else {
require_once '../lib/Review.class.php';
require_once '../lib/User.class.php';
require_once '../lib/Restaurant.class.php';
$user_id = $_POST['user_id'];
$restaurant_id = $_POST['restaurant_id'];
$rate = $_POST['rating'];
$content = $_POST['content'];
$fields = array('user_id' => $user_id, 'restaurant_id' => $restaurant_id, 'rating' => $rate, 'content' => $content);
try {
$new_review = new Review();
$restaurant = new Restaurant();
if ($restaurant->find($restaurant_id)) {
$original_rating = $restaurant->get_rating();
$new_rating = $rate;
$all_reviews = Review::get_all_reviews_by_restaurant($restaurant_id);
// var_dump($all_reviews);
if ($all_reviews) {
$overall_rate = 0;
while ($a_review = $all_reviews->fetch_row()) {
$overall_rate += $a_review[4];
}
$new_rating = ($overall_rate + $rate) / ($all_reviews->num_rows + 1);
}
$new_review->create($fields);
$restaurant->update_rating($new_rating);
$success = true;
$message = 'Adding review complete! Your review will be attached to the restaurant page shortly.';
示例15: test_restaurant_find
function test_restaurant_find()
{
//Arrange
$style = "Thai";
$test_cuisine = new Cuisine($style);
$test_cuisine->save();
$style2 = "asian fusion";
$test_cuisine2 = new Cuisine($style2);
$test_cuisine2->save();
$name = "Pok Pok";
$category_id = $test_cuisine->getId();
$test_restaurant = new Restaurant($name, $category_id);
$test_restaurant->save();
$name2 = "Mai Thai";
$category_id2 = $test_cuisine2->getId();
$test_restaurant2 = new Restaurant($name2, $category_id2);
$test_restaurant2->save();
//Act
$id = $test_restaurant->getId();
$result = Restaurant::find($id);
//Assert
$this->assertEquals($test_restaurant, $result);
}