O'Reilly logo

Laravel Application Development Blueprints by Halil İbrahim Yılmaz, Arda Kılıçdağı

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Taking orders

As you may remember, we've already created an order form in the cart.blade.php template file located at app/views/. Now we need to process the order. Let's code the OrderController.php file under app/controllers/:

<?php class OrderController extends BaseController { public function postOrder() { $rules=array( 'address'=>'required' ); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { return Redirect::route('cart')->with('error','Address field is required!'); } $member_id = Auth::user()->id; $address = Input::get('address'); $cart_books = Cart::with('Books')->where('member_id','=',$member_id)->get(); $cart_total=Cart::with('Books')->where('member_id','=',$member_id)->sum('total'); if(!$cart_books){ return ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required