public function getAccountIndex()
 {
     if (\Auth::account()->check()) {
         $user = \Auth::account()->get();
     } else {
         return Redirect::to("account/login")->with("error_message", "Login faild");
     }
     $user = \Auth::account()->get();
     return \View::make("account.index")->with("categories", \DB::table("categories")->get())->with("countries", \DB::table("country")->get())->with("myorders", \DB::table("orders")->where("customer_id", $user->id)->get())->with("statuses", \DB::table("order_status")->get());
 }
                    <div class="form-block">
                        <label for="email">Email address*</label>
                        <input type="email" id="email" name="email" required placeholder="email" value="<?php 
if (Auth::account()->check()) {
    echo $user->email;
} else {
    Input::old("email");
}
?>
 ">
                    </div>

                    <div class="form-block">
                        <label for="phone">Phone*</label>
                        <input type="text" id="phone" name="phone" placeholder="phone" required value="<?php 
if (Auth::account()->check()) {
    echo $user->phone;
} else {
    Input::old("phone");
}
?>
 ">
                    </div>

                    <div class="space20">&nbsp;</div>
                    @if(!Auth::account()->check())
                    <p>
                        <input type="checkbox" name="create_account" id="create_account">
                        <label for="create_account"><span></span> Create an account?</label>

 public function getAccountLogout()
 {
     Auth::account()->logout();
     return Redirect::to("/");
 }
 public function postCheckout()
 {
     $input = Input::get();
     $lastid = DB::table("orders")->max("id");
     $invoice_no = Order::invoiceNo($lastid);
     $input['invoice_no'] = $invoice_no;
     if (Auth::account()->check()) {
         $order = new Order();
         $user = Auth::account()->get();
         $order->invoice_no = $invoice_no;
         $order->firstname = $user->firstname;
         $order->lastname = $user->lastname;
         $order->phone = $user->phone;
         $order->email = $user->email;
         $order->company = $user->company;
         $order->address = $user->address;
         $order->apartment = $user->apartment;
         $order->city = $user->city;
         $order->state = $user->state;
         $order->country = $user->country;
         $order->customer_id = $user->id;
         if (isset($_POST['ship_billing'])) {
             $order->shipping_firstname = $input['firstname'];
             $order->shipping_lastname = $input['lastname'];
             $order->shipping_company = $input['company'];
             $order->shipping_address_1 = $input['apartment'];
             $order->shipping_address_2 = $input['address'];
             $order->shipping_city = $input['city'];
             $order->state = $input['state'];
             $order->shipping_country = $input['country'];
         } else {
             $order->shipping_firstname = $input['shipping_firstname'];
             //Auth::account()->firstname;
             $order->shipping_lastname = $input['shipping_lastname'];
             //Auth::account()->lastname;
             $order->shipping_company = $input['shipping_company'];
             //Auth::account()->company;
             $order->shipping_address_1 = $input['shipping_apartment'];
             //Auth::account()->apartment;
             $order->shipping_address_2 = $input['shipping_address'];
             //Auth::account()->address;
             $order->shipping_city = $input['shipping_city'];
             //Auth::account()->city;
             $order->shipping_state = $input['shipping_state'];
             //Auth::account()->state;
             $order->shipping_country = $input['shipping_country'];
             //Auth::account()->country;
         }
         $order->payment_firstname = $input['firstname'];
         $order->payment_lastname = $input['lastname'];
         $order->payment_company = $input['company'];
         $order->payment_address_1 = $input['apartment'];
         $order->payment_address_2 = $input['address'];
         $order->payment_city = $input['city'];
         $order->payment_state = $input['state'];
         $order->payment_method = $input['payment_method'];
         //$order->payment_postcode    =   $input['']
         $order->payment_country = $input['country'];
         /*Add independent items to the item table*/
         $input['email'] = $user->email;
         /**
          * Took away order->save
          */
     } else {
         if (isset($input['create_account'])) {
             $validation = Customer::validate(Input::all());
             $input = Input::all();
             if ($validation->fails()) {
                 return Redirect::back()->withErrors($validation)->withInput();
             } else {
                 array_forget($input, "_token");
                 array_forget($input, "confirmpassword");
                 array_forget($input, "submit");
                 array_forget($input, "ship_billing");
                 $customer = new Customer();
                 $customer->firstname = $input['firstname'];
                 $customer->lastname = $input['lastname'];
                 $customer->phone = $input['phone'];
                 $customer->email = $input['email'];
                 $customer->company = $input['company'];
                 $customer->address = $input['address'];
                 $customer->apartment = $input['apartment'];
                 $customer->city = $input['city'];
                 $customer->country = $input['country'];
                 $customer->password = Hash::make(Input::get("password"));
                 if ($customer->save()) {
                     /*Send Email to customer --TODO*/
                     $lastid = DB::table("orders")->max("id");
                     $invoice_no = Order::invoiceNo($lastid);
                     $input['invoice_no'] = $invoice_no;
                     $order = new Order();
                     $order->customer_id = $customer->id;
                     $order->invoice_no = $invoice_no;
                     $order->firstname = $input['firstname'];
                     $order->lastname = $input['lastname'];
                     $order->phone = $input['phone'];
                     $order->email = $input['email'];
                     $order->company = $input['company'];
                     $order->address = $input['address'];
                     $order->apartment = $input['apartment'];
                     $order->city = $input['city'];
                     $order->country = $input['country'];
                     $order->payment_firstname = $input['firstname'];
                     $order->payment_lastname = $input['lastname'];
                     //$order->payment_company         =   $input['company'];
                     $order->payment_address_1 = $input['apartment'];
                     $order->payment_address_2 = $input['address'];
                     $order->payment_city = $input['city'];
                     $order->payment_method = $input['payment_method'];
                     $order->payment_country = $input['country'];
                     if (isset($_POST['ship_billing'])) {
                         $order->shipping_firstname = $input['firstname'];
                         $order->shipping_lastname = $input['lastname'];
                         $order->shipping_company = $input['company'];
                         $order->shipping_address_1 = $input['apartment'];
                         $order->shipping_address_2 = $input['address'];
                         $order->shipping_city = $input['city'];
                         $order->state = $input['state'];
                         $order->shipping_country = $input['country'];
                     } else {
                         $order->shipping_firstname = $input['shipping_firstname'];
                         $order->shipping_lastname = $input['shipping_lastname'];
                         $order->shipping_company = $input['shipping_company'];
                         $order->shipping_address_1 = $input['shipping_apartment'];
                         $order->shipping_address_2 = $input['shipping_address'];
                         $order->shipping_city = $input['shipping_city'];
                         $order->shipping_state = $input['shipping_state'];
                         $order->shipping_country = $input['shipping_country'];
                     }
                     /**
                                             took away order->save for new customer
                     */
                 }
             }
         } else {
             //Section to be executed if customer does not want to register an account
             $lastid = DB::table("orders")->max("id");
             $invoice_no = Order::invoiceNo($lastid);
             $input['invoice_no'] = $invoice_no;
             $order = new Order();
             $order->invoice_no = $invoice_no;
             $order->firstname = $input['firstname'];
             $order->lastname = $input['lastname'];
             $order->phone = $input['phone'];
             $order->email = $input['email'];
             $order->company = $input['company'];
             $order->address = $input['address'];
             $order->apartment = $input['apartment'];
             $order->city = $input['city'];
             $order->country = $input['country'];
             //$order->customer_id             =   $invoice_id;
             if (isset($_POST['ship_billing'])) {
                 $order->shipping_firstname = $input['firstname'];
                 $order->shipping_lastname = $input['lastname'];
                 $order->shipping_company = $input['company'];
                 $order->shipping_address_1 = $input['apartment'];
                 $order->shipping_address_2 = $input['address'];
                 $order->shipping_city = $input['city'];
                 $order->shipping_country = $input['country'];
             } else {
                 $order->shipping_firstname = $input['shipping_firstname'];
                 $order->shipping_lastname = $input['shipping_lastname'];
                 $order->shipping_company = $input['shipping_company'];
                 $order->shipping_address_1 = $input['shipping_apartment'];
                 $order->shipping_address_2 = $input['shipping_address'];
                 $order->shipping_city = $input['shipping_city'];
                 $order->shipping_state = $input['shipping_state'];
                 $order->shipping_country = $input['shipping_country'];
             }
             $order->payment_firstname = $input['firstname'];
             $order->payment_lastname = $input['lastname'];
             $order->payment_company = $input['company'];
             $order->payment_address_1 = $input['apartment'];
             $order->payment_address_2 = $input['address'];
             $order->payment_city = $input['city'];
             $order->payment_method = $input['payment_method'];
             //$order->payment_postcode    =   $input['']
             $order->payment_country = $input['country'];
             /**
                            Took away order->save on non- registering customer
             */
         }
     }
     $order->shipping_method = $input['shipping_method'];
     $order->notes = $input['notes'];
     $order->order_status_id = 2;
     $order->total = Cart::total();
     $order->sub_total = Cart::total();
     //save order and perform other functionality
     /*Add independent items to the item table*/
     if ($order->save()) {
         $orderitems = Cart::content();
         foreach ($orderitems as $orderitem) {
             /*
              *|This section check for if product has a whole sale buying
              *|option i.e. if there is bulk purchase on carton or in Dozen
              *|$order item price changes to the carton or bulk purchase price
              *|chosen
              */
             /*
              *|insert purchased item(s) in to the orders_products
              *|table
              */
             /*Todo find betta way to do this with single object insert*/
             $total = $orderitem->qty * $orderitem->price;
             \DB::table('orders_products')->insert(['product_id' => $orderitem->id, 'order_id' => $order->id, 'product_name' => $orderitem->name, 'price' => $orderitem->price, 'quantity' => $orderitem->qty, 'total' => $total]);
             /*
              *|insert into order_option table to store
              *|product option selected by customers
              */
             /*Todo find betta way to do this with single object insert*/
             if ($orderitem->options && count($orderitem->options) > 0) {
                 foreach ($orderitem->options as $key => $value) {
                     $productoption = DB::table("products_options")->where("product_id", "=", $orderitem->id)->where("option_value", "=", $value)->get();
                     if (count($productoption) > 0) {
                         DB::table("orders_options")->insert(['order_id' => $order->id, 'product_id' => $orderitem->id, 'product_option_id' => $productoption[0]->product_option_value_id, 'product_option_value_id' => $productoption[0]->option_value_id, 'name' => $productoption[0]->option_type, "value" => $productoption[0]->option_value]);
                     }
                 }
             }
         }
         /* TODO Section to load options on products*/
         /*Send order info to customer as an invoice or notification*/
         $input['order_message'] = "";
         $input['order_footnote'] = "";
         $input['order_id'] = $order->id;
         Mail::send('emails.orderconfirmation', $input, function ($message) use($input) {
             $message->from("*****@*****.**", "Medical Equipment NG");
             $message->to($input['email'], "*****@*****.**")->cc('*****@*****.**')->subject("Order Confirmation: " . $input['invoice_no']);
         });
     }
     /*return View::make("success")->with("categories",DB::table("categories")->get())
       ->with("order",Order::find($order->id));*/
     return Redirect::route("success")->with("order", Order::find($order->id));
 }