public function getComponent() { $res = '<div class="form-group">'; $res .= parent::label(); $res .= parent::input(); $res .= parent::help(); $res .= '</div>'; return $res; }
/** * Redirect if input model not validated, only applicable for model * which extends Morphaworks\Database\Model * @param Morphaworks\Database\Model $model Model validated * @return [type] Redirect to previous URL with error message */ protected function formError(Morphaworks\Database\Model $model) { $messages = json_decode($model->getErrors(), true); $message = '<ul>'; foreach ($messages as $key => $value) { $message .= '<li>' . $value[0] . '</li>'; // append } $message .= '</ul>'; return Redirect::back()->with('error-message', $message)->withInput(Input::input()); }
public function getComponent() { if (parent::getType() == 'hidden') { return parent::input(); } $res = '<div class="form-group">'; $res .= parent::label(); $res .= parent::input(); $res .= parent::help(); $res .= '</div>'; return $res; }
public function handleSubmit() { $data = array_merge(Input::input(), $this->fileDetails('cover_letter'), $this->fileDetails('resume')); $client = new Guzzle\Http\Client(Config::get('remote.submit-domain')); $request = $client->post('submit', [], $data); $response = $request->send(); if ($response->isSuccessful()) { return Redirect::route('app.submit')->withInfo('You have successfully submitted.'); } else { return Redirect::route('app.submit')->withError('Your submission failed - try again, good luck.'); } }
private function doRequest($URI, $data = []) { Input::$input = $data; Laravel\Routing\Filter::register(require APP_PATH . 'filters' . EXT); $loader = new Laravel\Routing\Loader(APP_PATH, ROUTE_PATH); $router = new Laravel\Routing\Router($loader, CONTROLLER_PATH); IoC::instance('laravel.routing.router', $router); Laravel\Request::$route = $router->route(Laravel\Request::method(), Laravel\URI::current()); if (!is_null(Request::$route)) { $response = Request::$route->call(); } else { Laravel\Routing\Filter::run(['before'], [], true); $response = Laravel\Response::json(['msg' => 'Not found'], 404); \Laravel\Routing\Filter::run(['after'], [$response], true); } ob_start(); $response->send(); $output = ob_get_contents(); ob_end_clean(); return $output; }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { dd(Input::input('dni')); }
} } } /* |-------------------------------------------------------------------------- | Remove The Spoofer Input |-------------------------------------------------------------------------- | | The spoofed request method is removed from the input so it is not in | the Input::all() or Input::get() results. Leaving it in the array | could cause unexpected results since the developer won't be | expecting it to be present. | */ unset($input[Request::spoofer]); Input::$input = $input; /* |-------------------------------------------------------------------------- | Start The Application Bundle |-------------------------------------------------------------------------- | | The application "bundle" is the default bundle for the installation and | we'll fire it up first. In this bundle's bootstrap, more configuration | will take place and the developer can hook into some of the core | framework events such as the configuration loader. | */ Bundle::start(DEFAULT_BUNDLE); /* |-------------------------------------------------------------------------- | Auto-Start Other Bundles
/** * Resource create action * POST /resource * @return Response */ public function store($id) { // Get all form data. $data = Input::all(); // Create validation rules $unique = $this->unique(); $rules = array('title' => 'required|' . $unique, 'content' => 'required', 'category' => 'exists:job_categories,id', 'location' => 'required'); $slug = Input::input('title'); $hashslug = date('H.i.s') . '-' . md5($slug) . '.html'; // Custom validation message $messages = $this->validatorMessages; // Begin verification $validator = Validator::make($data, $rules, $messages); if ($validator->passes()) { // Verification success // Add resource $model = $this->model->find($id); $model->category_id = $data['category']; $model->title = e($data['title']); $model->location = e($data['location']); $model->slug = $hashslug; $model->content = e($data['content']); $model->meta_title = e($data['title']); $model->meta_description = e($data['title']); $model->meta_keywords = e($data['title']); $model->post_status = 'open'; $timeline = new Timeline(); $timeline->slug = $hashslug; $timeline->model = 'Job'; $timeline->user_id = Auth::user()->id; if ($model->save() && $timeline->save()) { // Add success return Redirect::route($this->resource . '.edit', $model->id)->with('success', '<strong>' . $this->resourceName . '添加成功:</strong>您可以继续编辑' . $this->resourceName . ',或返回' . $this->resourceName . '列表。'); } else { // Add fail return Redirect::back()->withInput()->with('error', '<strong>' . $this->resourceName . '添加失败。</strong>'); } } else { // Verification fail return Redirect::back()->withInput()->withErrors($validator); } }
/** * Action: Payment after add goods in shopping cart * @return Response */ public function payment() { $resourceName = '订单'; $resource = 'order'; // Get all form data. $data = Input::all(); $rules = array('product_id' => 'required|', 'customer_name' => 'required', 'customer_address' => 'required', 'customer_phone' => 'required|numeric'); // Custom validation message $messages = array('customer_name.required' => '请填写收货人姓名', 'customer_address.required' => '请填写收货地址', 'customer_phone.required' => '请填写您的手机号码', 'customer_phone.numeric' => '请填写正确的手机号码'); // Begin verification $validator = Validator::make($data, $rules, $messages); // Save user real name if (Auth::user()->username == NULL) { $user = Auth::user(); $user->username = Input::get('customer_name'); $user->save(); } // Save user mobile phone number if (Auth::user()->phone == NULL) { $user = Auth::user(); $user->phone = Input::get('customer_phone'); $user->save(); } $product_id = Input::input('product_id'); $product = Product::where('id', $product_id)->first(); $data = ShoppingCart::where('buyer_id', Auth::user()->id)->where('product_id', $product_id)->first(); if ($product->quantity < $data->quantity) { return Redirect::back()->with('error', '商品剩余数量不足'); } else { // Verification Success if ($validator->passes()) { $order_id = md5(date('his')) . $product_id . Auth::user()->id; $seller_id = $data->seller_id; $seller_alipay = User::where('id', $seller_id)->first()->alipay; $order_name = '时光碎片网购物-' . $product->title; $payment = $data->payment; $goods_show = 'http://www.timefragment.com/product/' . $product->slug; $customer_name = Input::input('customer_name'); $customer_address = Input::input('customer_address'); $customer_phone = Input::input('customer_phone'); // Create product order $product_order = $this->model; $product_order->order_id = $order_id; $product_order->seller_id = $seller_id; $product_order->product_id = $product_id; $product_order->customer_id = Auth::user()->id; $product_order->customer_address = $customer_address; $product_order->quantity = $data->quantity; $product_order->price = $data->price; $product_order->payment = $payment; $product_order->save(); // Destroy goods in shopping cart $data->delete(); // Alipay API require_once app_path('api/alipay/alipay.config.php'); require_once app_path('api/alipay/lib/alipay_submit.class.php'); // Request parameters $payment_type = "1"; // Payment type (required, don't modify) $notify_url = route('order.tradeNotify'); // Server asynchronous notification page URL (start with http://, don't use http://localhost/ or add ?id=123) $return_url = route('order.tradeReturn'); // Synchronization notification page URL (start with http://, don't use http://localhost/ or add ?id=123) $seller_email = $seller_alipay; // Saller Alipay ID (required) $out_trade_no = $order_id; // Order ID (required) $subject = $order_name; // Order name (required) $price = $payment; // Order payment (required) $quantity = "1"; // Goods quantity (default is 1) $logistics_fee = "0.00"; // Express payment (required) $logistics_type = "EXPRESS"; // Express type: EXPRESS, POST or EMS $logistics_payment = "SELLER_PAY"; // Express payment type (require:SELLER_PAY customer pay or BUYER_PAY saller pay) $body = $goods_show; // Order describe $show_url = $goods_show; // Goods show page (URL start with http://) $receive_name = $customer_name; // Customer name $receive_address = $customer_address; // Customer address $receive_zip = NULL; // Customer zip (code such as:123456) $receive_phone = NULL; // Custome telephone number (such as:0571-88158090) $receive_mobile = $customer_phone; // Customer mobile phone numer (such as:13312341234) // Constructs an array of arguments to request, no need to change $parameter = array("service" => "trade_create_by_buyer", "partner" => trim($alipay_config['partner']), "payment_type" => $payment_type, "notify_url" => $notify_url, "return_url" => $return_url, "seller_email" => $seller_email, "out_trade_no" => $out_trade_no, "subject" => $subject, "price" => $price, "quantity" => $quantity, "logistics_fee" => $logistics_fee, "logistics_type" => $logistics_type, "logistics_payment" => $logistics_payment, "body" => $body, "show_url" => $show_url, "receive_name" => $receive_name, "receive_address" => $receive_address, "receive_zip" => $receive_zip, "receive_phone" => $receive_phone, "receive_mobile" => $receive_mobile, "_input_charset" => trim(strtolower($alipay_config['input_charset']))); // Establishing request $alipaySubmit = new AlipaySubmit($alipay_config); $html_text = $alipaySubmit->buildRequestForm($parameter, "get", "确认付款"); echo $html_text; } else { return Redirect::back()->withInput()->withErrors($validator); } } }
/** * Delete metadata records * @return json */ public function destroy() { $id = Input::input('id'); $destroy = $this->doc->destroy($id); if (!$destroy) { return $this->response->errorBadRequest($this->doc->errors); } return $this->response->array($destroy); }
/** * 如果您在提交时同时填写了页面返回地址和后台返回地址,且地址相同,请在这里先做一次数据库查询判断订单状态,以防止重复处理该笔订单 * @return bool */ public function verify() { //获取交易应答的各项值 $merId = \Input::input('merid'); $orderId = \Input::input('orderno'); $transDate = \Input::input('transdate'); $amount = \Input::input('amount'); $currencyCode = \Input::input('currencycode'); $transType = \Input::input('transtype'); $status = \Input::input('status'); $checkValue = \Input::input('checkvalue'); // $gateId = \Input::input('GateId'); $orderNo = \Input::input('Priv1'); // $clock =\Input::input('clock'); //验证签名值,true 表示验证通过 $flag = $this->verifyResponse($merId, $orderId, $amount, $currencyCode, $transDate, $transType, $status, $checkValue); if ($flag) { if ($status == '1001') { //您的处理逻辑请写在这里,如更新数据库等。 $this->receiveAmount = $amount; $this->receiveTradeNo = $orderNo; $this->receiveOrderNo = $orderId; return true; } } return false; }