本文整理汇总了PHP中Restaurant::search方法的典型用法代码示例。如果您正苦于以下问题:PHP Restaurant::search方法的具体用法?PHP Restaurant::search怎么用?PHP Restaurant::search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Restaurant
的用法示例。
在下文中一共展示了Restaurant::search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search
/**
* @param $query - The search query used to find restaurants
*/
public function search($query)
{
$results = Restaurant::search($query);
echo json_encode($results);
}
示例2: array
$restaurant->save();
$cuisine = Cuisine::find($cuisine_id);
return $app['twig']->render('cuisine.html.twig', array('cuisine' => $cuisine, 'restaurants' => $cuisine->getRestaurants()));
});
//Reviews page
$app->get("/restaurants/{id}", function ($id) use($app) {
$restaurant = Restaurant::find($id);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => $restaurant->getReviews()));
});
$app->post("/reviews", function () use($app) {
$username = $_POST['username'];
$date = $_POST['date'];
$rating = $_POST['rating'];
$comment = $_POST['comment'];
$restaurant_id = $_POST['restaurant_id'];
$review = new Review($username, $date, $rating, $comment, $restaurant_id, $id = null);
$review->save();
$restaurant = Restaurant::find($restaurant_id);
return $app['twig']->render('restaurant.html.twig', array('restaurant' => $restaurant, 'reviews' => Review::getAll()));
});
//Cuisine_edit page
$app->get("/cuisines/{id}/edit", function ($id) use($app) {
$cuisine = Cuisine::find($id);
return $app['twig']->render('cuisine_edit.html.twig', array('cuisine' => $cuisine));
});
//Search result page
$app->get("/search", function () use($app) {
$search = Restaurant::search($_GET['search']);
return $app['twig']->render('search.html.twig', array('search' => $search, 'search_term' => $_GET['search']));
});
return $app;
示例3: Restaurant
<body>
<?php
include "./include/navbar.php";
?>
<div class="container" style="margin-top:100px;margin-bottom:50px;min-height:500px">
<?php
if (isset($_POST['location'])) {
?>
<h1>Search: <?php
echo $_POST['location'];
?>
</h1>
<div class="col-sm-8">
<?php
$restaurant = new Restaurant();
$data = $restaurant->search($_POST['location']);
if (sizeof($data) > 0) {
foreach ($data as $key => $value) {
echo '<div class="row" restaurant-id="' . $value['id'] . '">
<div class="col-sm-2">
<a href="/restaurants.php?id=' . $value['id'] . '"><img src=".' . $value['image'] . '" height="90px" width="90px"></a>
</div>
<div class="col-sm-6">
<a href="/restaurants.php?id=' . $value['id'] . '"><h4>' . ($key + 1) . '. ' . $value['name'] . '</h4></a>
<h4>' . $value['rating'] . ' star rating ' . $value['review_count'] . ' reviews</h4>
</div>
<div class="col-sm-4">
<h5>' . $value['address1'] . '</h5>
<h5>' . $value['address2'] . '</h5>
<h5>' . $value['phone'] . '</h5>
</div>