コード例 #1
0
 public function run()
 {
     DB::table('menus')->delete();
     DB::table('dish_menu')->delete();
     DB::table('recommendations')->delete();
     $menu = new Menu();
     $menu->menu_date = "2014-03-30";
     $menu->save();
     foreach (Dish::all() as $dish) {
         $menu->dishes()->save($dish);
     }
     $menu = new Menu();
     $menu->menu_date = "2014-04-23";
     $menu->save();
     foreach (Dish::all() as $dish) {
         $menu->dishes()->save($dish);
     }
     $recommendation = new Recommendation();
     $recommendation->menu_id = 1;
     $recommendation->recommendation = "Today, we has abcxyz for menu 1";
     $recommendation->save();
     $recommendation = new Recommendation();
     $recommendation->menu_id = 2;
     $recommendation->recommendation = "Today, we has abcxyz for menu 2";
     $recommendation->save();
 }
コード例 #2
0
 public function postEditDish($id)
 {
     /* validate input */
     $validator = Validator::make(Input::all(), array("name" => "required|unique:dishes", "price" => "required|integer", "description" => "required"));
     /* if validated */
     if ($validator->passes()) {
         /* get input */
         $dish = Dish::find($id);
         $dish->name = Input::get("name");
         $dish->price = Input::get("price");
         $dish->description = Input::get("description");
         if (Input::has("new_category")) {
             $category = DishCategory::where("name", "=", Input::get("new_category"))->first();
             if ($category) {
                 $dish->dish_category_id = $category->id;
             } else {
                 $category = new DishCategory();
                 $category->name = Input::get("new_category");
                 $category->save();
                 $dish->dish_category_id = $category->id;
             }
         } else {
             $dish->dish_category_id = Input::get("dish_category_id");
         }
         $dish->save();
         return Redirect::to("admin/dish/edit_dish/{$dish->id}")->with('message', 'Dish edited!');
     } else {
         return Redirect::to("admin/dish/edit_dish/{$dish->id}")->withErrors($validator);
     }
     // end validation
 }
コード例 #3
0
 public function postCreateMenu()
 {
     /* validate input */
     $validator = Validator::make(Input::all(), array("menu_date" => "required|date_format:Y-m-d", "dishes" => "required", "recommendation" => "required"));
     /* if validated */
     if ($validator->passes()) {
         /* get input */
         $menu = new Menu();
         $menu->menu_date = Input::get("menu_date");
         $menu->save();
         $recommendation = new Recommendation();
         $recommendation->menu_id = $menu->id;
         $recommendation->recommendation = Input::get("recommendation");
         $recommendation->save();
         foreach (Input::get('dishes') as $dishId) {
             $menu->dishes()->save(Dish::find((int) $dishId));
         }
         return Redirect::to('admin/menu/create_menu')->with('message', 'Menu added!');
     } else {
         return Redirect::to('admin/menu/create_menu')->withErrors($validator);
     }
     // end validation
 }
コード例 #4
0
 public function postDeleteDish($id = null)
 {
     if (!isset($id) or is_null($id)) {
         return Redirect::to('/admin/dishes');
     }
     $dish = Dish::find($id);
     if (is_null($dish)) {
         return Redirect::to('/admin/dishes');
     }
     $dish->delete();
     return Redirect::to('/admin/dishes');
 }
コード例 #5
0
ファイル: dishes.php プロジェクト: Ukesh2010/aila
<?php

require_once '../admin/classes/connection.class.php';
require_once '../admin/classes/dish.class.php';
?>



<div class="col-md-4">
<h2>Ai-La Special Dishes</h2>
<table class="table table-bordered">
 <?php 
$featureObj = new Dish();
$view = $featureObj->viewdish();
// echo '<pre>';
//  print_r($view);
//  echo '<pre>';
?>
       
        <?php 
foreach ($view as $value) {
    ?>
<tr>
	<td><?php 
    echo $value['dish_title'];
    ?>
</td>
    <td><?php 
    echo $value['dish_price'];
    ?>
</td>
コード例 #6
0
<?php

require_once '../classes/connection.class.php';
require_once '../classes/dish.class.php';
require_once '../classes/locate.class.php';
if (isset($_POST['submit'])) {
    $dish_id = $_POST['dish_id'];
    $dish_title = $_POST['title'];
    $dish_price = $_POST['price'];
}
$updatedishObject = new Dish();
$updatedishObject->setdishID($dish_id);
$updatedishObject->setdishTitle($dish_title);
$updatedishObject->setdishprice($dish_price);
$flag = $updatedishObject->updatedish();
// echo '<pre>';
// print_r($flag);
// echo '</pre>';
// exit;
if ($flag) {
    $_SESSION['dish_updated'] = $err = "The dish has been updated successfully";
    new Locate('../index.php?page=dish&action=view');
} else {
    $_SESSION['dish_not_updated'] = $err = "The dish couldn't be updated";
    new Locate('../index.php?page=dish&action=view');
}
コード例 #7
0
 /**
  * add a dish order to a delivery
  *
  * @param $deliveryId
  * @param $dishId
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postAddOrder($deliveryId, $dishId)
 {
     $delivery = Delivery::find($deliveryId);
     $dish = Dish::find($dishId);
     // if delivery and dish is not loaded correctly
     if (!$delivery || !$dish) {
         return Redirect::back()->with('errors', new MessageBag(['An error has occurred.']));
     }
     // if delivery closed
     if (!$delivery->is_active) {
         return Redirect::back()->with('errors', new MessageBag(['Delivery already closed.']));
     }
     // place order
     $order = new Order();
     // attach to relations
     $order->user()->associate(Auth::user());
     $order->delivery()->associate($delivery);
     $order->dish()->associate($dish);
     $order->save();
     // messages
     $messages = new MessageBag();
     $messages->add('success', 'Successfully ordered a dish!');
     $messages->add('success', 'The order has been attached to the delivery.');
     return Redirect::back()->with('messages', $messages);
 }
コード例 #8
0
ファイル: Dishmanager.php プロジェクト: MaximeBoubel/cookinn
 /**
  * Update data of a dish
  * @param Dish $dish 
  */
 public function update(Dish $dish)
 {
     $query = $this->_db->prepare('UPDATE dish SET name = :name, origin = :origin, time_to_cook = :time_to_cook WHERE dish_id = :dish_id');
     $query->execute(array('name' => $dish->getName(), 'origin' => $dish->getOrigin(), 'time_to_cook' => $dish->getTimeToCook(), 'dish_id' => $dish->getDishId()));
 }
コード例 #9
0
ファイル: view_dish.php プロジェクト: Ukesh2010/aila
<?php

require_once 'classes/connection.class.php';
require_once 'classes/dish.class.php';
$viewobj = new Dish();
$views = $viewobj->viewdish();
/*echo '<pre>';
print_r($views);
echo '</pre>';*/
?>



<table class="table" width="698" border="1">
  <tbody>
    <tr>
      <th width="71" scope="row"><strong>dishID</strong></th>
      <td width="47"><strong>dish Title</strong></td>
      <td width="69"><strong>dish Price</strong></td>
      
      
      <td colspan="2"><strong>Action</strong></td>
    </tr>
   
    <?php 
if (sizeof($views > 0)) {
    foreach ($views as $value) {
        ?>
    <tr>
      <th scope="row">&nbsp; <?php 
        echo $value['dish_id'];
コード例 #10
0
 public function get_dishdata_by_id($dishid)
 {
     $dish_data = Dish::findFirst($dishid)->toArray();
     return $dish_data;
 }
コード例 #11
0
<?php

//require_once('../bootstrap.php');
//session_start();
require_once 'classes/connection.class.php';
require_once 'classes/dish.class.php';
require_once 'classes/locate.class.php';
$dish_id = isset($_GET['dish_id']) ? $_GET['dish_id'] : '';
$objdelete = new Dish();
$objdelete->setdishID($dish_id);
$flag = $objdelete->deletedish();
/*echo $objdelete->sql;
exit;*/
/*echo '<pre>';
print_r($flag);
echo'</pre>';
exit;*/
if ($flag) {
    //echo "post already deleted";
    new Locate('index.php?page=dish&action=view');
    $_SESSION['msg'] = $objdelete->msg = "dish deleted sucessfully";
} else {
    header('location:../index.php?page=dish&action=view&err=dishnotdeleted');
}
コード例 #12
0
ファイル: process_add_dish.php プロジェクト: Ukesh2010/aila
<?php

session_start();
require_once '../classes/connection.class.php';
require_once '../classes/dish.class.php';
$adddishobj = new Dish();
/*echo '<pre>';
print_r($adddishobj);
echo '</pre>';
exit;
*/
$dish_id = mysqli_real_escape_string($adddishobj->conxn, $_POST['dish_id']);
$dish_title = mysqli_real_escape_string($adddishobj->conxn, $_POST['title']);
$dish_price = mysqli_real_escape_string($adddishobj->conxn, $_POST['price']);
$adddishobj->setdishID($dish_id);
$adddishobj->setdishTitle($dish_title);
$adddishobj->setdishprice($dish_price);
//$adduserobj->setError($er);
//$adduserobj->setMessage($msg);
$adddishobj->adddish();
/*echo '<pre>';
print_r ($adduserobj);
echo '</pre>';
exit;*/
if ($adddishobj) {
    header('location:../index.php?page=dish&action=view');
    $_SESSION['msg'] = $adddishobj->msg = "The dish has been added sucessfully";
} else {
    echo $_SESSION['msg'] = $adddishobj->msg = "Sorry the dish has not been  added, please try again later";
}
コード例 #13
0
ファイル: update_dish.php プロジェクト: Ukesh2010/aila
<?php

include 'classes/connection.class.php';
include 'classes/dish.class.php';
$dish_id = isset($_GET['dish_id']) ? (int) $_GET['dish_id'] : '';
$objdish = new Dish();
$objdish->setdishID($dish_id);
$views = $objdish->viewdish();
/*echo '<pre>';
print_r($views);
echo '</pre>';*/
foreach ($views as $value) {
    ?>
<form name="form1" method="post" action="process/process_update_dish.php">
  <table width="669" border="1">
    <tbody>
      <tr>
        <th colspan="2" scope="row">Please Edit dish</th>
      </tr>
      <tr>
        <th scope="row">Title</th>
        <td>
		<input type="text" name="title" value="
		<?php 
    echo $value['dish_title'];
    ?>
"/>		
		
        
      </tr>
      <tr>
コード例 #14
0
 public function run()
 {
     DB::table('dish_categories')->delete();
     DB::table('dish_images')->delete();
     DB::table('dishes')->delete();
     $dishCategory = new DishCategory();
     $dishCategory->name = "category1";
     $dishCategory->save();
     $dish = new Dish();
     $dish->name = "Boiled Eggs";
     $dish->dish_category_id = $dishCategory->id;
     $dish->price = 10;
     $dish->description = "this is item1 by country1";
     $dish->save();
     $dishImage = new DishImage();
     $dishImage->dish_id = $dish->id;
     $dishImage->link = "http://besthomechef.com.au/wp/wp-content/uploads/2012/11/hard-boiled-eggs.jpg";
     $dishImage->save();
     $dishCategory = new DishCategory();
     $dishCategory->name = "category2";
     $dishCategory->save();
     $dish = new Dish();
     $dish->name = "Pancake";
     $dish->dish_category_id = $dishCategory->id;
     $dish->price = 20;
     $dish->description = "this is item2 by country2";
     $dish->save();
     $dishImage = new DishImage();
     $dishImage->dish_id = $dish->id;
     $dishImage->link = "http://besthomechef.com.au/wp/wp-content/uploads/2012/11/hard-boiled-eggs.jpg";
     $dishImage->save();
     $dishCategory = new DishCategory();
     $dishCategory->name = "category3";
     $dishCategory->save();
     $dish = new Dish();
     $dish->name = "Pasta Bolognese";
     $dish->dish_category_id = $dishCategory->id;
     $dish->price = 30;
     $dish->description = "this is item3 by country3";
     $dish->save();
     $dishImage = new DishImage();
     $dishImage->dish_id = $dish->id;
     $dishImage->link = "http://besthomechef.com.au/wp/wp-content/uploads/2012/11/hard-boiled-eggs.jpg";
     $dishImage->save();
     $dish = new Dish();
     $dish->name = "Beef Stroganoff";
     $dish->dish_category_id = $dishCategory->id;
     $dish->price = 30;
     $dish->description = "this is item3 by country3";
     $dish->save();
     $dishImage = new DishImage();
     $dishImage->dish_id = $dish->id;
     $dishImage->link = "http://besthomechef.com.au/wp/wp-content/uploads/2012/11/hard-boiled-eggs.jpg";
     $dishImage->save();
     $dish = new Dish();
     $dish->name = "Beef Wellington";
     $dish->dish_category_id = $dishCategory->id;
     $dish->price = 30;
     $dish->description = "this is item3 by country3";
     $dish->save();
     $dishImage = new DishImage();
     $dishImage->dish_id = $dish->id;
     $dishImage->link = "http://besthomechef.com.au/wp/wp-content/uploads/2012/11/hard-boiled-eggs.jpg";
     $dishImage->save();
     $dish = new Dish();
     $dish->name = "Caesar Salad";
     $dish->dish_category_id = $dishCategory->id;
     $dish->price = 30;
     $dish->description = "this is item3 by country3";
     $dish->save();
     $dishImage = new DishImage();
     $dishImage->dish_id = $dish->id;
     $dishImage->link = "http://besthomechef.com.au/wp/wp-content/uploads/2012/11/hard-boiled-eggs.jpg";
     $dishImage->save();
 }
コード例 #15
0
ファイル: account.php プロジェクト: armourjami/armourtake
 public function dishes()
 {
     $flash_string = '';
     if (Session::exists('account')) {
         $flash_string = Session::flash('account');
     }
     $user = new User();
     if ($user->isLoggedIn()) {
         //The products table will be rendered on the view page
         $dishes = Dish::toArray();
         $this->view('account/dishes', ['register' => true, 'loggedIn' => 1, 'flash' => $flash_string, 'name' => $user->data()->name, 'page_name' => 'Dishes', 'dishes' => json_encode($dishes), 'user_id' => $user->data()->id]);
     } else {
         Session::flash('home', 'You have been logged out, please log back in');
         Redirect::to('home');
     }
 }
コード例 #16
0
 /**
  * @param int $storeId
  */
 private function createNewDish($storeId)
 {
     $faker = $this->getFakeGenerator();
     Dish::create(array('store_id' => $storeId, 'store_dish_id' => $faker->numberBetween(1, 99), 'name' => $faker->word, 'price' => $faker->randomFloat(2, '2.00', '12.99') * 100));
 }