public function postSetInitial(Request $request) { $session_id = $request->input('session_id'); $input = ['session_id' => $session_id]; $validator = validator::make($request->all(), ['session_id' => 'required']); if ($validator->fails()) { return ApiResponseClass::errorResponse('You Have Some Input Errors. Please Try Again!!', $input, $validator->errors()); } else { $user_registered_to_school = UsersRegisteredToSchool::where('user_id', Auth::user()->id)->get()->first(); if ($user_registered_to_school) { $user_registered_to_session = UsersRegisteredToSession::where('session_id', $session_id)->where('user_id', Auth::user()->id)->get()->first(); if ($user_registered_to_session) { return ApiResponseClass::successResponse($user_registered_to_session, $input); } $user_registered_to_session = new UsersRegisteredToSession(); $user_registered_to_session->session_id = $session_id; $user_registered_to_session->school_id = $user_registered_to_school->school_id; $user_registered_to_session->user_id = Auth::user()->id; $user_registered_to_session->save(); if ($user_registered_to_session->save()) { return ApiResponseClass::successResponse($user_registered_to_session, $input); } } } return ApiResponseClass::errorResponse('There is Something Wrong. Please Try Again!!', $input); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $user_id = Auth::User()->id; if (Input::file()) { $file_image = array('image' => Input::file('file_image')); $rules = array('image' => 'required'); $validator = validator::make($file_image, $rules); if ($validator->fails()) { return redirect::to('photo')->withInput()->withErrors($validator); } else { if (Input::file('file_image')->isValid()) { $path = '../public/images'; $extension = Input::file('file_image')->getClientOriginalExtension(); $fileName = rand() . '.' . $extension; Input::file('file_image')->move($path, $fileName); Image::create(array('user_id' => $user_id, 'path' => $fileName)); Session::flash('success', 'Upload successfully'); return Redirect::to('photo'); } else { Session::flash('error', 'uploaded file is not valid'); return Redirect::to('photo'); } } } }
private function __checkdata($contentData) { $nodeMdl = app::get('sysinfo')->model('article_nodes'); $validator = validator::make(['title' => $contentData['title'], 'node_id' => $contentData['node_id']], ['title' => 'required', 'node_id' => 'required'], ['title' => '资讯标题不能为空', 'node_id' => '资讯节点id不能为空']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { throw new LogicException($error[0]); } } $nodeInfo = $nodeMdl->getRow('parent_id', array('node_id' => $contentData['node_id'])); if ($nodeInfo['parent_id'] == 0) { throw new \LogicException('请选择二级分类!'); } $data['node']['node_id'] = $contentData['node_id']; $data['article']['content'] = $contentData['content']; $data['article']['node_id'] = $contentData['node_id']; $data['article']['title'] = $contentData['title']; $data['article']['platform'] = $contentData['platform']; $data['article']['article_logo'] = $contentData['article_logo']; $data['article']['modified'] = time(); $data['article']['platform'] = $contentData['platform']; if ($contentData['article_id']) { $data['article']['article_id'] = $contentData['article_id']; } return $data; }
public function save() { $post = input::get(); $ruledata = $post['ruledata']; $H = $post['_DTIME_']['H']; $M = $post['_DTIME_']['M']; foreach ($H as $key => $val) { $ruledata[$key] = strtotime($post[$key] . " " . $val . ":" . $M[$key]); } $validator = validator::make(array('0' => $ruledata['buy_limit'], '1' => $ruledata['discount_min'], '2' => $ruledata['discount_max'], '3' => date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '4' => date('Y-m-d H:i:s', $ruledata['apply_end_time']), '5' => date('Y-m-d H:i:s', $ruledata['release_time']), '6' => date('Y-m-d H:i:s', $ruledata['start_time']), '7' => date('Y-m-d H:i:s', $ruledata['end_time']), '8' => $ruledata['shoptype'], '9' => $ruledata['limit_cat'], '10' => $ruledata['activity_name'], '11' => $ruledata['activity_tag']), array('0' => 'min:0', '1' => 'numeric|min:0.01|max:99.99', '2' => 'numeric|max:99.99|min:' . $ruledata['discount_min'], '3' => 'after:' . date('Y-m-d H:i:s', time()), '4' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_begin_time']), '5' => 'after:' . date('Y-m-d H:i:s', $ruledata['apply_end_time']), '6' => 'after:' . date('Y-m-d H:i:s', $ruledata['release_time']), '7' => 'after:' . date('Y-m-d H:i:s', $ruledata['start_time']), '8' => 'required', '9' => 'required', '10' => 'required|max:20', '11' => 'required|max:10'), array('0' => '用户限购数量要大于0!', '1' => '折扣必须是数字|折扣范围必须大于0|折扣范围必须小于100', '2' => '折扣必须是数字|折扣范围必须小于100|折扣范围必须由小到大!', '3' => '活动报名的开始时间必须大于当前时间!', '4' => '活动报名结束时间必须大于报名的开始时间!', '5' => '发布时间必须大于报名结束时间!', '6' => '活动生效时间必须大于活动发布时间!', '7' => '活动生效结束时间必须大于活动开始时间!', '8' => '至少选择一种店铺类型!', '9' => '至少选择一种平台商品类目!', '10' => '|活动名称长度必须小于20', '11' => '|活动标签长度必须小于10')); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { return $this->splash('error', null, $error[0]); } } $this->begin("?app=syspromotion&ctl=admin_activity&act=index"); try { kernel::single('syspromotion_activity')->saveActivity($ruledata); $this->adminlog("添加活动{$post['activity_name']}", 1); } catch (Exception $e) { $this->adminlog("添加活动{$post['activity_name']}", 0); $msg = $e->getMessage(); $this->end(false, $msg); } $this->end(true); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request) { $url = $request->input('url'); //验证提交的url $target = ['url' => $url]; $roule = ['url' => 'required|url']; $message = ['url' => $url . '不是合法的url', 'required' => '请求输入url']; $validator = validator::make($target, $roule, $message); if ($validator->fails()) { return redirect('url')->withErrors($validator); } //检测在数据库 $result = Url::where('url', $url)->first(); //dd($result); if ($result) { return view('url.result')->with('short_url', $result->short_url); } //检测不在数据库 $short_url = Url::get_short_url(); $res = Url::insert(['url' => $url, 'short_url' => $short_url]); if ($res) { return view('url.result')->with('short_url', $short_url); } else { return '数据添加失败'; } }
public function TambahJadwal() { $rules = array('unit_id' => 'required', 'kategori' => 'required', 'tglstart' => 'required', 'tglases' => 'required', 'tglfinish' => 'required', 'detail' => 'required'); $messages = array('unit_id.required' => 'Nama Jabatan Harus Terisi', 'kategori.required' => 'Kategori Harus Dipilih', 'tglstart.required' => 'Tanggal Mulai Harus Terisi', 'tglases.required' => 'Tanggal Asessment Harus Terisi', 'tglfinish.required' => 'Tanggal Selesai Harus Terisi', 'detail.required' => 'Detail Harus terisi'); $validasi = validator::make(Input::all(), $rules, $messages); if ($validasi->fails()) { return Redirect::back()->withErrors($validasi)->withInput(); } else { $kat = Input::get('kategori'); if ($kat == 'internal') { $aa = "in"; } else { $aa = "ex"; } DB::transaction(function ($aa) use($aa) { //asesment promosi $jadwal = KandidatPromote::create(['unit_staf_id' => Input::get('unit_id'), 'tgl_awal' => Input::get('tglstart'), 'tgl_asesment' => Input::get('tglases'), 'tgl_selesai' => Input::get('tglfinish'), 'detail' => Input::get('detail')]); //rekrutmen rekap header $rekap_header = HeaderRekap::create(['id_asesmen' => $jadwal->id, 'kategori' => Input::get('kategori'), 'nama' => Input::get('jabatan'), 'tanggal_awal' => Input::get('tglstart'), 'tanggal_akhir' => Input::get('tglfinish'), 'deksripsi' => Input::get('detail')]); //asessment promosi daftar $daftar = KandidatPromosiDaftar::create(['asesment_promosi_id' => $jadwal->id, 'nip' => Input::get('nip'), 'detail' => Input::get('detail')]); //rekrutment rekap profiling $profil = ProfilingRekap::create(['id_rekap' => $rekap_header->id, 'kategori' => $aa, 'nip' => $daftar->nip, 'id_jabatan' => $jadwal->unit_staf_id]); }); Session::flash('message', 'Berhasil Menambahkan Jadwal Asessment'); return Redirect::to('career/jadwal/lihat/asessment'); } }
public function signin(Request $request) { $input = $request->all(); $validator = validator::make($input, ['username' => 'required|exists:user', 'password' => 'required']); if (Auth::attempt(['username' => $input['username'], 'password' => $input['password'], 'activated' => 1])) { return redirect(route('default.home')); } else { return redirect()->back()->withErrors('Invalid Credentials or user not active.'); } }
private function __checkQuantity($quantity) { $quantityValidate = ['bn' => 'required|max:30', 'quantity' => 'required|numeric']; $validator = validator::make($quantity, $quantityValidate); if ($validator->fails()) { $errors = json_decode($validator->messages(), 1); foreach ($errors as $error) { throw new LogicException($error[0]); } } }
function saving($model) { if (!is_null($model->published_at)) { $rules['published_at'] = ['date']; $validator = validator::make($model->toArray(), $rules); if ($validator->fails()) { $model->setErrors($validator->messages()); return false; } } }
private function __checkdata($data) { $validator = validator::make(['shop_id' => $data['shop_id'], 'item_id' => $data['item_id'], 'sku_id' => $data['sku_id'], 'email' => $data['email']], ['shop_id' => 'required', 'item_id' => 'required', 'sku_id' => 'required', 'email' => 'required|email'], ['shop_id' => '店铺id不能为空!', 'item_id' => '商品id不能为空!', 'sku_id' => '货品id不能为空!', 'email' => '邮件不能为空!|邮件格式不正确!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { throw new LogicException($error[0]); } } return $data; }
/** * Show the form for creating a new resource. * * @return Response */ public function postCreate() { // $validator = validator::make(Input::all(), Category::$rules); if ($validator->passes()) { $category = new Category(); $category->name = Input::get('name'); $category->save(); return Redirect::to('admin/categories/index')->with('message', 'Category Created'); } return Redirect::to('admin/categories/index')->with('message', 'Something went wrong')->withErrors($validator)->withInput(); }
public function postCreate(Request $request) { $email = $request->input('email'); $password = $request->input('password'); $password_again = $request->input('password_again'); $inputs = ['email' => $email, 'password' => $password, 'password_again' => $password_again]; $validator = validator::make($request->all(), ['email' => 'required|unique:users|email', 'password' => 'required|max:16|min:6', 'password_again' => 'required|same:password']); if ($validator->fails()) { return ApiResponseClass::errorResponse('You Have Some Input Errors', $inputs, $validator->errors()); } $isUrlUser = $request->is('user/*'); $isUrlAdmin = $request->is('admin/*'); $isUrlTeacher = $request->is('teacher/*'); $group_id = null; if ($isUrlUser) { $group_id = Groups::Student_Group_Id; } elseif ($isUrlAdmin) { $group_id = Groups::Administrator_Group_ID; } elseif ($isUrlTeacher) { $group_id = Groups::Teacher_Group_Id_Group_ID; } DB::beginTransaction(); try { Groups::findorFail($group_id); $user = new User(); $user->email = $email; $user->password = Hash::make('password'); $user->activated = 0; $user->email_updated_at = date("Y-m-d h:i:s"); $user->password_updated_at = date("Y-m-d h:i:s"); $user->activation_code = str_random(64); if (!$user->save()) { throw new \ErrorException(); } $user_group = new UsersGroups(); $user_group->user_id = $user->id; $user_group->groups_id = $group_id; if (!$user_group->save()) { throw new \ErrorException(); } DB::commit(); } catch (ModelNotFoundException $e) { DB::rollback(); return ApiResponseClass::errorResponse('ModelNotFoundException', $inputs); } catch (\ErrorException $e) { DB::rollback(); return ApiResponseClass::errorResponse('ModelNotSavedException', $inputs); } // Send mail to the user if not the test Shop Id. return ApiResponseClass::successResponse($user, $inputs); }
public function postChat($partner_id) { $validator = validator::make(Request::all(), Message::$rules); $user = Auth::user(); $partner = User::find($partner_id); if ($validator->passes()) { $message = new Message(); $message->sender_id = $user->id; $message->receiver_id = $partner_id; $message->content = Request::input('content'); $message->save(); } $messages = $user->chat($partner_id); //return view('messages.chat')->with('messages', $messages)->with('user', $user)->with('partner', $partner); return redirect('messages/chat/' . $partner_id); }
public function storeMessage(Request $request, Ngo $ngo) { $rules = ['sender' => 'required|max:255', 'subject' => 'required|max:255', 'body' => 'required|min:20']; $validator = validator::make(Input::all(), $rules); if ($validator->fails()) { return redirect('/envy/' . $ngo->user_id . '/contact-us')->withErrors($validator); } else { $message = new Message(); $message->user_id = $ngo->user_id; $message->sender = $request->sender; $message->message_subject = $request->subject; $message->message_body = $request->body; $message->sent_date = (new DateTime())->format('Y-m-d H:i:s'); $message->save(); return redirect('/envy/' . $ngo->user_id . '/contact-us'); } }
private function __checkItems($item) { if (!is_array($item)) { throw new LogicException('item参数格式不正确'); } $deliveryDetailValidate = array('oid' => 'required', 'num' => 'required|numeric'); foreach ($item as $k => $val) { $validator = validator::make($val, $deliveryDetailValidate); if ($validator->fails()) { $errors = json_decode($validator->messages(), 1); foreach ($errors as $error) { throw new LogicException($error[0]); } } $newItem[$k]['oid'] = $val['oid']; $newItem[$k]['number'] = $val['num']; } return $newItem; }
private function __getItems($tradeId, $shopId, $items, &$tradeInfo) { //将数据从json格式转化为array $items = json_decode($items, 1); $fields = 'tid,shop_id,user_id,status,post_fee,dlytmpl_id,orders.bn,' . 'orders.num,orders.oid,orders.title,orders.sku_id'; //获取订单的订单详情,并且返回这个订单数据 $requestParams = ['tid' => $tradeId, 'fields' => $fields]; $tradeInfo = app::get('syslogistics')->rpcCall('trade.get', $requestParams); $ordersInfo = $tradeInfo['orders']; $fmt_ordersInfo = array(); // foreach ($ordersInfo as $orderInfo) { $skuBn = $orderInfo['bn']; $fmt_ordersInfo[$skuBn] = $orderInfo; } //这里是对item的数据的验证 $deliveryDetailValidate = array('num' => 'required|numeric', 'bn' => 'required'); $newItems = []; foreach ($items as $item) { //验证每个item的数据格式的正确性 $it = []; $validator = validator::make($item, $deliveryDetailValidate); if ($validator->fails()) { $errors = json_decode($validator->messages(), 1); foreach ($errors as $error) { throw new LogicException($error[0]); } } //TODO order的数据格式 $bn = $item['bn']; if ($fmt_ordersInfo[$bn] == null) { throw new LogicException("该订单中,货品不存在。bn:" . $bn); } $it['bn'] = $bn; $it['oid'] = $fmt_ordersInfo[$bn]['oid']; $it['num'] = $item['num']; $it['title'] = $fmt_ordersInfo[$bn]['title']; $it['sku_id'] = $fmt_ordersInfo[$bn]['sku_id']; $newItems[] = $it; } return $newItems; }
public function commitAftersalesApply() { $postdata = input::get(); $validator = validator::make(['reason' => $postdata['reason']], ['reason' => 'required'], ['reason' => '取消原因必选!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { return $this->splash('error', null, $error[0]); } } try { $result = app::get('topc')->rpcCall('aftersales.apply', input::get(), 'buyer'); } catch (\LogicException $e) { $msg = $e->getMessage(); return $this->splash('error', $url, $msg, true); } $url = url::action('topc_ctl_member_aftersales@aftersalesList'); $msg = '售后申请提交成功'; return $this->splash('success', $url, $msg, true); }
/** * Show the form for creating a new resource. * * @return Response */ public function postCreate() { // $validator = validator::make(Input::all(), Product::$rules); if ($validator->passes()) { $product = new Product(); $product->category_id = Input::get('category_id'); $product->title = Input::get('title'); $product->description = Input::get('description'); $product->price = Input::get('price'); $image = Input::file('image'); $filename = date('Y-m-d-H-i-s') . "-" . $image->getClientOriginalName(); Image::make($image->getRealPath())->resize(468, 249)->save('images/products/' . $filename); $product->image = 'images/products/' . $filename; $product->save(); $product->save(); return Redirect::to('admin/products/index')->with('message', 'Product Created'); } return Redirect::to('admin/products/index')->with('message', 'Something went wrong')->withErrors($validator)->withInput(); }
public function Kirim() { $rules = array('golongann' => 'required', 'pendidikan' => 'required'); $messages = array('golongann.required' => 'pangkat dan Golongan Harus Terpilih', 'pendidikan.required' => 'Jenjang Pendidikan Harus Terpilih '); $validasi = validator::make(Input::all(), $rules, $messages); if ($validasi->fails()) { return Redirect::back()->withErrors($validasi)->withInput(); } else { $data = Input::get(); $golong = array_keys($data['golongann']); $datagolongan = array_values($data['golongann']); $prasyarat = array_keys($data['pendidikan']); //mengecek key dari array kunci lima -> pendidikan[5][] $datanilai = array_values($data['pendidikan']); //mengambil data value foreach ($datanilai['0'] as $a) { //print_r(array_keys($data['pendidikan'])); //print_r(array_values($data['pendidikan'])); /*$bobok[] = array( 'asesment_prasyarat_id'=>input::get('kel_jab'), 'nilai'=>$a, 'asesment_prasyarat_id'=>$prasyarat['0'] );*/ $proses = new Prasyarat(); $proses->asesment_eselon_id = Input::get('kel_jab'); $proses->asesment_prasyarat_id = $prasyarat['0']; $proses->nilai = $a; $proses->save(); } foreach ($datagolongan['0'] as $b) { $proses = new Prasyarat(); $proses->asesment_eselon_id = Input::get('kel_jab'); $proses->asesment_prasyarat_id = $golong['0']; $proses->nilai = $b; $proses->save(); } Session::flash('message', 'Berhasil Menambahkan Prasyarat Jabatan'); return Redirect::to('career/prasyarat'); } }
public static function paramsValidate($params, $paramsInfos) { if (is_array($paramsInfos)) { //获取参数设定,组织成一validator的要求格式 $paramsValidate = []; $paramsName = []; foreach ($paramsInfos['params'] as $paramKey => $paramsInfo) { $paramsValidate[$paramKey] = $paramsInfo['valid']; //$paramsName[$paramKey] = $paramsInfo['description']; } //这里验证数据 $validator = validator::make($params, $paramsValidate); if ($validator->fails()) { $errors = json_decode($validator->messages(), 1); foreach ($errors as $error) { throw new LogicException($error[0]); } } } else { throw new LogicException('params设置异常'); } }
public function proses() { $rules = array('ta' => 'required', 'sasaran' => 'required', 'jmlhari' => 'required', 'kuota' => 'required', 'anggaran' => 'required', 'tglmulai' => 'required', 'tglselesai' => 'required'); $messages = array('ta.required' => 'Ada Beberapa Data Belum Terpilih ', 'sasaran.required' => 'Sasaran Tujuan Belum Terisi ', 'jmlhari.required' => 'Jumlah Hari Diklat Belum Terisi', 'kuota.required' => 'Kuota Belum Terisi', 'anggaran.required' => 'Anggaran Belum Terisi', 'tglmulai.required' => 'Tanggal Mulai Belum Di pilih', 'tglselesai.required' => 'Tanggal Selesai Belum Di pilih'); $validasi = validator::make(Input::all(), $rules, $messages); if ($validasi->fails()) { return Redirect::to('admin/diklat/diklat/tambah')->withErrors($validasi)->withInput(); } else { $proses = new DiklatEvaluasi(); $proses->id_diklat_comp = Input::get('ta'); $proses->sasaran = Input::get('sasaran'); $proses->kuota = Input::get('kuota'); $proses->jmlhari = Input::get('jmlhari'); $proses->anggaran = Input::get('anggaran'); $proses->jdwal_mulai = Input::get('tglmulai'); $proses->jdwal_selesai = Input::get('tglselesai'); $proses->save(); Session::flash('message', 'Berhasil Tambah Diklat Sudah Di Tambahkan'); return Redirect::to('admin/diklat/perencanaan'); } $breadcrumbs = array(array("Assessment Internal" => "javascript:void(0)"), array("Pengaturan" => ""), array("Kandidat Promosi Jabatan" => "")); $this->layout->content = View::make('competency::adminevaluasi/tambah', compact('kompetensi')); }
public function cancelOrderBuyer() { $reasonSetting = config::get('tradeCancelReason'); $reasonPost = input::get('cancel_reason'); $validator = validator::make($reasonPost, ['required'], ['取消原因必选!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { return $this->splash('error', null, $error[0]); } } if ($reasonPost == "other") { $cancelReason = input::get('other_reason'); $validator = validator::make($cancelReason, ['required'], ['取消原因必须填写!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { return $this->splash('error', null, $error[0]); } } } else { $cancelReason = $reasonSetting['user'][$reasonPost]; } $params['tid'] = input::get('tid'); $params['user_id'] = userAuth::id(); $params['cancel_reason'] = $cancelReason; try { app::get('topc')->rpcCall('trade.cancel', $params, 'buyer'); } catch (Exception $e) { $msg = $e->getMessage(); return $this->splash('error', null, $msg, true); } $url = url::action('topc_ctl_member_trade@tradeList'); $msg = app::get('topc')->_('订单取消成功'); return $this->splash('success', $url, $msg, true); }
/** * @author: Arham * @param Request $request * @param: none * desc: validate the form, store customer details to database and generate a * unique id and if the registration success then send an e-mail to customer * created : 24/03/2016 */ public function regpromotion(Request $request) { $nm = null; $lnm = null; $ad = null; $mail = null; $phone = null; $rid = 0; $validate2 = validator::make(input::all(), array('first_name' => 'required|alpha', 'last_name' => 'required|alpha|different:first_name', 'email' => 'required|email|unique:regpromotion', 'contact_number' => 'required|unique:regpromotion|digits:10', 'address' => 'required')); $rp = 0; if ($validate2->fails()) { return view('pages\\Discount\\registerpromotion', ['rp' => $rp, 'nm' => $nm, 'lnm' => $lnm, 'ad' => $ad, 'mail' => $mail, 'phone' => $phone, 'rid' => $rid])->withErrors($validate2); } $fname = Input::get('first_name'); $lname = Input::get('last_name'); $email = Input::get('email'); $cno = Input::get('contact_number'); $address = Input::get('address'); $cid1 = Auth::user()->id; $id = DB::table('regpromotion')->select('cid')->get(); foreach ($id as $id1) { if ($cid1 == $id1->cid) { $rid = 1; return view('pages\\Discount\\registerpromotion', ['rp' => $rp, 'nm' => $nm, 'lnm' => $lnm, 'ad' => $ad, 'mail' => $mail, 'phone' => $phone, 'rid' => $rid])->withErrors($validate2); } } function generateRandomString($length = 10) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } $prokey = generateRandomString(); Mail::send('pages/discount/promotionmail', array("prokey" => $prokey, 'fname' => $fname, 'lname' => $lname), function ($message) { $message->from('*****@*****.**'); $message->to(Input::get('email'))->subject('Paint Buddy Promotion'); }); $rp = DB::table('regpromotion')->insert(array('fname' => $fname, 'lname' => $lname, 'email' => $email, 'contact_number' => $cno, 'address' => $address, 'promotionID' => $prokey, 'cid' => $cid1)); return view('pages\\Discount\\registerpromotion', ['rp' => $rp, 'nm' => $nm, 'lnm' => $lnm, 'ad' => $ad, 'mail' => $mail, 'phone' => $phone, 'rid' => $rid])->withErrors($validate2); }
public function canregistered_apply_save() { $params = input::get(); $apiData['shop_id'] = $this->shopId; $apiData['activity_id'] = (int) $params['activity_id']; //判断重复提交 $data['activity_id'] = (int) $params['activity_id']; $data['shop_id'] = $this->shopId; $registered_activity = app::get('topshop')->rpcCall('promotion.activity.register.list', $data, 'seller'); if ($registered_activity['data']) { $msg = '该活动不能已经报过名了,不可以重复报名!'; return $this->splash('error', null, $msg); } $itemWithPrice = array(); if (!$params['item_activity_price']) { $msg = '您还没有选择商品,请重新选择!'; return $this->splash('error', null, $msg); } foreach ($params['item_activity_price'] as $itemId => $activityPrice) { $validator = validator::make([$activityPrice, $itemId], ['required|numeric', 'required|numeric'], ['请设置商品价格!|商品价格格式有误!', '请设置活动商品!|请勿使用非法手段更改商品数据!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { return $this->splash('error', null, $error[0]); } } $itemWithPrice[] = $itemId . ':' . $activityPrice; } $apiData['item_info'] = implode(';', $itemWithPrice); //echo '<pre>';print_r($apiData);exit(); try { // 活动报名保存 $result = app::get('topshop')->rpcCall('promotion.activity.register', $apiData, 'seller'); } catch (\LogicException $e) { $msg = $e->getMessage(); $url = url::action('topshop_ctl_promotion_activity@canregistered_apply', array('activity_id' => $params['activity_id'])); return $this->splash('error', $url, $msg, true); } $url = url::action('topshop_ctl_promotion_activity@activity_list'); $msg = app::get('topshop')->_('申请活动保存成功'); return $this->splash('success', $url, $msg, true); }
public function update_password(Request $request) { if ($request->isMethod('post')) { $rules = array('previous_password' => 'required|min:6', 'new_password' => 'required|min:6', 'retype_password' => 'required|same:retype_password'); $validator = validator::make($request->all(), $rules); if ($validator->fails()) { return redirect('update_password')->withErros('validator')->withInput(); } else { if (Auth::attempt(['email' => Auth::user()->email, 'password' => $request->previous_password])) { $user = user::findorfail(Auth::user()->id); $user->fill(['password' => Hash::make($request->new_password)])->save(); Session::flash('success_msg', 'Your password succesfully Updated'); return redirect('update_password'); } else { Session::flash('error_msg', 'Your Password Not Match'); return Redirect('update_password'); } } } return view('blog.update_password'); }
public function deleteNode($data) { $nodeMdl = app::get('sysinfo')->model('article_nodes'); $articleMdl = app::get('sysinfo')->model('article'); $validator = validator::make(['node_id' => $data['node_id']], ['node_id' => 'required'], ['node_id' => '节点id不能为空!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { throw new LogicException($error[0]); } } /*if(!$data['node_id']) { throw new \LogicException('节点id不能为空!'); }*/ $article = $articleMdl->getList('article_id', array('node_id' => $data['node_id'])); if ($article) { throw new \LogicException('该节点下面存在文章,请先删除文章!'); } if ($data['parent_id'] == 0) { $hasChildren = $nodeMdl->getList('node_id', array('parent_id' => $data['node_id'])); if ($hasChildren) { throw new \LogicException('该节点下面存在子节点,请先删除子节点!'); } } $nodeDelete = $nodeMdl->delete(array('node_id' => $data['node_id'])); if ($nodeDelete) { return true; } else { return false; } }
public function postLogin(Request $request) { $loginValidation = validator::make($request->all(), ['loginemail' => 'required|email|exists:users,email', 'loginpassword' => 'required|min:8']); if ($loginValidation->fails()) { return redirect::back()->withErrors($loginValidation->errors())->withInput(Input::except('password')); } else { /* *getting the email and password that user has typed in form */ $loginData = array('email' => Input::get('loginemail'), 'password' => Input::get('loginpassword'), 'confirmed' => 1, 'type' => 'user'); if (Auth::validate($loginData)) { if (Auth::attempt($loginData)) { return Redirect::intended('home'); } } else { // if any error send back with message. Session::flash('error', 'Invalid Email/Password Combination'); return Redirect::to('startjourney'); } } }
/** * 检查密码是否合法,密码是否一致(注册,找回密码,修改密码)调用 * * @params string $pwd 密码 * @params string $pwdConfirm 确认密码 * * @return bool */ public function checkPwd($pwd, $pwdConfirm) { $validator = validator::make(['password' => $pwd, 'password_confirmation' => $pwdConfirm], ['password' => 'min:6|max:20|confirmed'], ['password' => '密码长度不能小于6位!|密码长度不能大于20位!|输入的密码不一致!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { throw new LogicException($error[0]); } } return true; }
private function __checkAccount($username) { $validator = validator::make(['username' => $username], ['username' => 'numeric|email'], ['username' => '用户名不能为纯数字!|用户名不能为邮箱!']); if ($validator->fails()) { $messages = $validator->messagesInfo(); foreach ($messages as $error) { throw new LogicException($error[0]); } } return true; }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { $input = $request->all(); $rules = ['username' => 'unique:user,username|required|min:5|max:30|unique:user,username', 'email' => 'required|email|unique:user,email', 'firstname' => 'required', 'lastname' => 'required', 'middlename' => 'required', 'usergroup_id' => 'required|integer|exists:usergroup,id', 'password' => 'required|min:5', 'confirmpassword' => 'required|min:5|same:password']; $v = validator::make($input, $rules); if ($v->fails()) { return redirect()->back()->withErrors($v->messages()->first())->withInput($input); } $input['id'] = $file = $this->create_barcode($this->user->generate_id()); //create the barcode first $filename = $file . "." . $this->imagebarcodetype; //create the filename based on the barcode. $filepath = $this->imagebarcodepath . "/"; //create the full path of the file $endfile = $filepath . $filename; //create the final path + name of the file if ($user = $this->user->store($input)) { $userbarcode = $this->userbarcode->store($user, $filename); $user->barcode_id = $userbarcode->id; if (file_exists($endfile) && $user && $userbarcode) { $user->save(); return redirect(route('auth.login'))->with('flash_message', 'User successfully registered.'); } else { if ($userbarcode) { $this->userbarcode->fdelete($userbarcode); } if ($user) { $this->user->fdelete($user); } return redirect()->back()->withErrors('Cannot save userbarcode. Try Again'); } } return redirect()->back()->withErrors('Could not save user'); }