function myplaceorder(Request $request) { if ($request['place'] == 1) { $order_address = new order_address(); $order_address->type = "himself"; $order_address->name = $request['name']; $order_address->phone = (string) $request['Contact Number']; $order_address->pincode = $request['postalcode']; $order_address->address = $request['address']; $order_address->message = $request['Personalized']; $order_address->order_id = $request['productid']; $order_address->save(); $token = $request['productid']; $order_token = new product_token(); $order_token->u_id = Session::get('uid'); $order_token->order_id = $token; $return_key = md5($token . rand()); $order_token->order_token = $return_key; $order_token->save(); $api = new Instamojo('b0702bd721ad77f700aa98e4b5a8832a', 'aec9d4a72e40263ea010f35beae47f96'); try { $response = $api->linkCreate(array('title' => 'Gags By Mail', 'description' => 'Create a new Link easily', 'base_price' => Session::get('price', 0), 'currency' => 'INR', 'redirect_url' => 'http://.' . $_SERVER['HTTP_HOST'] . './sucess/' . $return_key)); $user = user::find(Session::get('uid')); //dd($user); return redirect($response['url'] . "?data_name=" . $user->name . "&data_email=" . $user->email . "&data_readonly=data_name&data_readonly=data_email"); } catch (Exception $e) { print 'Error: ' . $e->getMessage(); } } elseif ($request['place'] == 2) { $victimorder = new order_address(); $victimorder->type = "victim"; $victimorder->name = $request['name1']; $victimorder->address = $request['address1']; $victimorder->city = $request['city1']; $victimorder->pincode = $request['pincode1']; $victimorder->phone = $request['po1']; $victimorder->message = $request['message1']; $victimorder->order_id = $request['productid']; $victimorder->save(); $token = $request['productid']; $order_token = new product_token(); $order_token->u_id = Session::get('uid'); $order_token->order_id = $token; $return_key = md5($token . rand()); $order_token->order_token = $return_key; $order_token->save(); $api = new Instamojo('b0702bd721ad77f700aa98e4b5a8832a', 'aec9d4a72e40263ea010f35beae47f96'); try { $response = $api->linkCreate(array('title' => 'Gags By Mail', 'description' => 'Create a new Link easily', 'base_price' => Session::get('price', 0), 'currency' => 'INR', 'redirect_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/sucess/' . $return_key)); $user = user::find(Session::get('uid')); //dd($user); return redirect($response['url'] . "?data_name=" . $user->name . "&data_email=" . $user->email . "&data_readonly=data_name&data_readonly=data_email"); } catch (Exception $e) { print 'Error: ' . $e->getMessage(); } } else { echo "f**k u mother f****r"; } /* $api = new Instamojo('b0702bd721ad77f700aa98e4b5a8832a', 'aec9d4a72e40263ea010f35beae47f96'); try { $response = $api->linkCreate(array( 'title'=>'Gags By Mail', 'description'=>'Create a new Link easily', 'base_price'=>Session::get('price',0), 'currency'=>'INR', 'redirect_url'=>'http://localhost:8000/sucess/'.$return_key )); $user=user::find(Session::get('uid')); //dd($user); return redirect($response['url']."?data_name=".$user->name."&data_email=".$user->email."&data_readonly=data_name&data_readonly=data_email"); } catch (Exception $e) { print('Error: ' . $e->getMessage()); }*/ }
function sucess($token) { $product_token = product_token::where('order_token', $token)->get(); //dd($product_token); $order_id = ""; foreach ($product_token as $orders) { $order_id = $orders->order_id; $orders->order_info = 1; $orders->save(); } $item_id = array(); $items = order::where('order_id', $order_id)->get(); foreach ($items as $item) { array_push($item_id, $item->item_id); } $order_address = order_address::where('order_id', $order_id)->get(); Mail::send(['text' => 'mailse'], ['address' => $order_address, 'item' => $item_id], function ($m) { $m->to('*****@*****.**', 'schoolboy')->subject('Your Reminder!'); }); Mail::send(['text' => 'mailse'], ['address' => $order_address, 'item' => $item_id], function ($m) { $m->to('*****@*****.**', 'schoolboy')->subject('Your Reminder!'); }); return view('sucess'); //$loginfo=Session::put('loginfo'); }