本文整理汇总了PHP中Illuminate\Support\Facades\Validator类的典型用法代码示例。如果您正苦于以下问题:PHP Validator类的具体用法?PHP Validator怎么用?PHP Validator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Validator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getValidationErrorsHtml
/**
* @param \Illuminate\Support\Facades\Validator $validator
* @return string
*/
public static function getValidationErrorsHtml($validator)
{
$temp = '';
foreach ($validator->messages()->all('<li>:message</li>') as $message) {
$temp .= $message;
}
return '<ul>' . $temp . '</ul>';
}
开发者ID:wcoder,项目名称:basont,代码行数:12,代码来源:ModelHelper.php
示例2: adAnnounce
public function adAnnounce(Request $request)
{
$data = ["name" => $request->name, "email" => $request->email, "phone" => $request->phone, "description" => $request->description, "chambres" => $request->chambres, "pieces" => $request->pieces, "surface" => $request->surface, "prix" => $request->prix, "aid" => $request->aid];
$file = null;
$data["email"] = $request->email;
$input = array('image' => Input::file('image'));
$rules = array('image' => 'image');
$validator = Validator::make($input, $rules);
if ($validator->fails()) {
return response()->json(['data' => 'Fichier invalid', 'state' => false]);
} else {
if ($request->hasFile('image')) {
$file = $request->file('image');
$filename = $file->getClientOriginalName();
$destinationPath = public_path() . '/uploads/ad';
$file->move($destinationPath, $filename);
$data['image'] = asset('uploads/ad/' . $filename);
$manager = new \MongoDB\Driver\Manager('mongodb://localhost:27017');
$collection = new \MongoDB\Collection($manager, 'builders', 'ads');
$stat = ['email' => $request->email, 'data' => $data, 'created' => new \DateTime("now")];
try {
$collection->insertOne($stat);
} catch (\Exception $e) {
return response()->json(['state' => false]);
}
return response()->json(['data' => $data, 'state' => true]);
}
}
}
开发者ID:Symfomany,项目名称:laravelcinema,代码行数:29,代码来源:AdController.php
示例3: performValidation
/**
* @param $command
* @throws EntryValidationException
*/
protected function performValidation($command)
{
$validator = Validator::make($command->input, $this->rules);
if ($validator->fails()) {
throw new EntryValidationException($validator);
}
}
开发者ID:jjsoft-ar,项目名称:siges-core,代码行数:11,代码来源:ValidateEntryData.php
示例4: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store(Request $request)
{
// validate the inputs
$validator = Validator::make($data = $request->all(), $this->user->rules);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
}
// fill the user with the inputs and save to DB
unset($data['password_conf']);
$this->user->fill($data);
$this->user->password = Hash::make($this->user->password);
$maxid = User::all()->max('id');
if ($maxid == 0) {
$this->user->account_type = 99;
} else {
$this->user->account_type = 1;
}
$this->user->active = 0;
$this->user->activation_token = uniqid();
$this->user->save();
// send activation email
$this->user->sendActivationEmail();
Auth::logout();
return view('notifications.accountsuccess', ['title' => 'Account Created!']);
}
开发者ID:DevTrad,项目名称:tradbiz,代码行数:30,代码来源:UserController.php
示例5: store
/**
* Handle an authentication attempt.
*
* @return Response
*/
public function store()
{
$rules = array('email' => 'required|email', 'password' => 'required');
$validate = Validator::make(Input::all(), $rules);
if ($validate->fails()) {
return Redirect::to('/');
} else {
if (Auth::attempt(array('email' => Input::get('email'), 'password' => Input::get('password'), 'status' => 'Activate'))) {
/*$user = User::where('email','=',$email)->get();
Session::put('user_type',$user[0]->role);
$id = $user[0]->id;
Session::put('created_by',$id);*/
Session::put('user_id', Auth::user()->id);
Session::put('user_name', Auth::user()->username);
Session::put('user_role', Auth::user()->role);
Session::flash('message', 'User has been Successfully Login.');
$roles = Auth::user()->role;
if ($roles = 'admin' || 'manager') {
return Redirect::to('dashboard');
} elseif ($roles = 'user') {
return Redirect::to('profile');
}
} else {
Session::flash('message', 'Your username or password incorrect');
return Redirect::to('/');
}
}
}
开发者ID:woakes070048,项目名称:cemcoErp,代码行数:33,代码来源:AuthController.php
示例6: boot
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//Used to check if surf start is before end. Can't surf time travel :)
Validator::extend('surftime', function ($attribute, $value, $parameters, $validator) {
return $value >= $parameters[0];
});
}
开发者ID:shauno,项目名称:sesh.co.za,代码行数:12,代码来源:SeshApiProvider.php
示例7: postOrder
public function postOrder()
{
log::debug('postOrder::Input params');
log::debug(Input::all());
//Validation rules
$rules = array('pizza_marinara' => array('required', 'integer', 'between:0,3'), 'pizza_margherita' => array('required', 'integer', 'between:0,3'), 'olio' => array('min:1|max:20'), 'name' => array('required', 'min:1|max:20'), 'email' => array('required', 'email', 'min:1|max:20'), 'freeOrder' => array('exists:menu,dish'));
// The validator
$validation = Validator::make(Input::all(), $rules);
// Check for fails
if ($validation->fails()) {
// Validation has failed.
log::error('Validation has failed');
$messages = $validation->messages();
$returnedMsg = "";
foreach ($messages->all() as $message) {
$returnedMsg = $returnedMsg . " - " . $message;
}
log::error('Validation fail reason: ' . $returnedMsg);
return redirect()->back()->withErrors($validation);
}
log::debug('Validation passed');
$msg = array('email' => Input::get('email'), 'name' => Input::get('name'));
$response = Event::fire(new ExampleEvent($msg));
$response = Event::fire(new OrderCreated($msg));
return view('orderdone', ['msg' => $msg]);
}
开发者ID:WebYourMind,项目名称:courses-laravel5,代码行数:26,代码来源:NewOrderController.php
示例8: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store($jenis)
{
if ($jenis == 'kategori') {
$rules = array("judul" => "required", "status" => "required");
$data = new Kategori();
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$data->judul = strtolower(Input::get('judul'));
$data->aktif = Input::get('status');
$data->save();
return redirect('/bos/kategori');
} else {
return back()->withInput()->with('message', 'Lengkapi data terlebih dahulu');
}
}
if ($jenis == 'artikel') {
$rules = array("judul" => "required");
$valid = Validator::make(Input::all(), $rules);
if ($valid->passes()) {
$data = new Artikel();
$data->judul = ucwords(Input::get('judul'));
$data->slug = strtolower(str_replace(" ", "-", trim(Input::get('judul'))));
$data->kategori = Input::get('kategori');
$data->aktif = Input::get('aktif');
$data->isi = Input::get('isi');
$data->save();
return redirect('/bos/artikel');
} else {
return back()->withInput()->with('message', 'Lengkapi data anda terlebih dahulu');
}
}
}
开发者ID:andreepratama27,项目名称:melayupedia,代码行数:37,代码来源:BlogController.php
示例9: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'year' => 'required']);
if ($validator->fails()) {
return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
}
//example of delete exist file
$existMeetingReport = MeetingReport::where('year', '=', $request->get('year'))->where('no', '=', $request->get('no'))->first();
if ($existMeetingReport != null) {
$filename = base_path() . '/public/uploads/Meeting-reports/' . $request->get('year') . '/' . $existMeetingReport->file_path;
if (File::exists($filename)) {
File::delete($filename);
}
MeetingReport::destroy($existMeetingReport->id);
}
if (Input::file('file')->isValid()) {
$filePath = $request->get('no') . '.pdf';
if (Input::file('file')->move(base_path() . '/public/uploads/Meeting-reports/' . $request->get('year'), $filePath)) {
$meetingReport = new MeetingReport();
$meetingReport->file_path = $filePath;
$meetingReport->year = $request->get('year');
$meetingReport->no = $request->get('no');
$meetingReport->save();
return redirect('/admin/management');
} else {
return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
}
}
}
开发者ID:nettanawat,项目名称:Sfu-laravel,代码行数:35,代码来源:MeetingreportController.php
示例10: validate
public static function validate($data, $specialRules = [])
{
if (isset($specialRules['idRule']) && $specialRules['idRule']) {
static::$rules['id'] = 'required|between:1,10';
}
return Validator::make($data, static::$rules);
}
开发者ID:syscover,项目名称:pulsar,代码行数:7,代码来源:TerritorialArea2.php
示例11: postRegister
public function postRegister()
{
$rules = ['email' => 'required|email', 'ngo-name' => 'required|min:5', 'ngo-desc' => 'string|min:20', 'ngo-email' => 'required|email', 'ngo-phone' => 'required|min:7'];
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return redirect('/envy/auth/register')->withErrors($validator)->withInput();
} else {
$user = User::where('user_email', Input::get('email'))->first();
if ($user && !$user->is_user_ngo) {
$user->is_user_ngo = true;
$user->save();
$ngo = new Ngo();
$ngo->user_id = $user->user_id;
$ngo->ngo_name = Input::get('ngo-name');
$ngo->ngo_email = Input::get('ngo-email');
$ngo->ngo_phone = Input::get('ngo-phone');
$ngo->ngo_description = Input::get('ngo-desc');
$ngo->save();
}
// $user = new User;
// $user->user_name = Input::get('name');
// $user->user_email = Input::get('email');
// $user->password = Hash::make(Input::get('password'));
// $user->is_user_ngo = true;
// $user->save();
return redirect('/envy/auth/login');
}
}
开发者ID:umarhussain15,项目名称:web_semester_project_integration_repo_Jan16,代码行数:28,代码来源:MyAuthController.php
示例12: sendContactForm
public function sendContactForm()
{
$is_mail_sent = false;
// Get data
$lastname = post('lastname');
$firstname = post('firstname');
$email = post('email');
$subject = post('subject');
$message_body = post('message');
$inputs = ['lastname' => $lastname, 'firstname' => $firstname, 'email' => $email, 'subject' => $subject, 'message' => $message_body];
$rules = ['lastname' => 'required', 'firstname' => 'required', 'email' => 'required|email', 'subject' => 'required', 'message' => 'required'];
$messages = ['lastname.required' => 'contactForm.lastname_required', 'firstname.required' => 'contactForm.firstname_required', 'email.required' => 'contactForm.email_required', 'email.email' => 'contactForm.email_invalid', 'subject.required' => 'contactForm.subject_required', 'message.required' => 'contactForm.message_required'];
// Data Validation
$validator = Validator::make($inputs, $rules, $messages);
if ($validator->fails()) {
$messages = $validator->messages();
$this->page["inputs"] = $inputs;
$this->page["messages"] = $messages;
return;
}
$data = compact('firstname', 'lastname', 'email', 'subject', 'message_body');
$is_mail_sent = Mail::send('algad.bootstrap::mail.contactform.message', $data, function ($message) use($firstname, $lastname, $email) {
$message->from($email, $firstname . " " . $lastname);
$message->addReplyTo($email, $lastname . ' ' . $firstname);
$message->to($this->getProperty('recipient_email'));
});
if ($is_mail_sent) {
$this->page["contact_success_message"] = $this->getProperty('email_sent_confirmation');
} else {
$this->page["contact_error_message"] = $this->getProperty('email_sent_failed');
}
}
开发者ID:janusnic,项目名称:OctoberCMS-Bootstrap,代码行数:32,代码来源:ContactForm.php
示例13: postEdit
public function postEdit(Request $request)
{
$validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required', 'gender' => ['required', 'in:male,female'], 'password' => 'min:6', 'martial_status' => ['in:single,engaged,married']]);
if ($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator);
}
if ($request->has('password') && $request->has('password_confirmation')) {
if ($request->password === $request->password_confirmation) {
Auth::user()->password = Hash::make($request->password);
Auth::user()->save();
} else {
return redirect()->back()->withInput()->with('errors', ['Passwords does not match.']);
}
}
$user = Auth::user();
$user->first_name = $request->first_name;
$user->last_name = $request->last_name;
$user->gender = $request->gender;
$user->birth_date = $request->has('birth_date') ? $request->birth_date : null;
$user->phone = $request->has('phone') ? $request->phone : null;
$user->bio = $request->has('bio') ? $request->bio : null;
$user->marital_status = $request->has('marital_status') ? $request->marital_status : null;
$user->save();
return redirect()->route('profile.edit')->with('info', 'your profile has been updated');
}
开发者ID:KareemBadawy,项目名称:Flarian,代码行数:25,代码来源:ProfileController.php
示例14: postCreate
public function postCreate()
{
$validator = Validator::make(Input::all(), Order::$rules);
if ($validator->passes()) {
$order = new Order();
$order->user_id = Auth::id();
$order->delivery_address = Input::get('delivery_address');
$order->sum = Cart::total();
$order->payment_type = Input::get('payment_type');
$order->save();
foreach (Cart::content() as $cart_item) {
$order_product = new OrderProduct();
$order_product->order_id = $order->id;
$order_product->product_id = $cart_item->id;
$order_product->qty = $cart_item->qty;
$order_product->sum = $cart_item->price;
$order_product->save();
}
Cart::destroy();
if ($order->payment_type == 0) {
//pay card
return Redirect::to('order/pay');
}
return Redirect::to('cart/confirmed')->with('message', 'Заказ оформлен.');
}
return Redirect::to('cart/confirm')->with('message', 'Проверьте корректность заполнения полей!')->withErrors($validator)->withInput();
}
开发者ID:venomir,项目名称:tc,代码行数:27,代码来源:OrderController.php
示例15: create
public function create()
{
$p = new Post();
$inputs = \Input::all();
$rules = array('title' => 'required', 'metadescription' => 'required', 'content' => 'required', 'tags' => 'required', 'photo' => 'required', 'category' => 'required');
$validation = Validator::make($inputs, $rules);
if ($validation->fails()) {
return var_dump($validation->errors());
} else {
$p->title = \Input::get('title');
$p->metadescription = \Input::get('metadescription');
$p->content = \Input::get('content');
$p->tags = \Input::get('tags');
$p->category = \Input::get('category');
// $p->photo = \Input::get('photo');
if ($file = \Input::file('photo')) {
//getting timestamp
$timestamp = str_replace([' ', ':'], '-', Carbon::now()->toDateTimeString());
$name = $timestamp . '-' . $file->getClientOriginalName();
$file->move(public_path() . '/uploads/', $name);
$p->photo = '/uploads/' . $name;
} else {
return 'Pic Not uploaded Properly! Press Back Button';
}
$p->save();
return \Redirect::route('adminsite')->with('alert', 'Publication created successfully!');
}
}
开发者ID:devasanibharath,项目名称:Laravel-Complete-blog,代码行数:28,代码来源:AdminController.php
示例16: createUser
/**
* This function create a new user after validate the request with the class NewUserRequest
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createUser(Request $request)
{
switch ($request->input('type')) {
//only for facebook user
case 'facebook':
$rules = ['email' => 'email|required', 'firstname' => 'required', 'facebook_id' => 'required', 'token' => 'required'];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return response()->json($validator->errors(), 400);
}
return $this->loginFacebookUser($request);
break;
//For every new user
//For every new user
default:
$rules = ['email' => 'email|required', 'firstname' => 'required', 'password' => 'required'];
$validator = Validator::make($request->all(), $rules);
if ($validator->fails()) {
return response()->json($validator->errors(), 400);
}
$user = new User();
$user->fill($request);
if (!$user->save()) {
return response()->json('Error, the user was not created', 400);
}
return response()->json('success', 200);
}
}
开发者ID:jarriaga,项目名称:endaroo,代码行数:33,代码来源:UserController.php
示例17: validate
public static function validate($data, $specialRules = [])
{
if (isset($specialRules['group'])) {
static::$rules['group'] = '';
}
return Validator::make($data, static::$rules);
}
开发者ID:syscover,项目名称:pulsar,代码行数:7,代码来源:CustomField.php
示例18: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validator = Validator::make($request->all(), ['file' => 'mimes:pdf', 'name' => 'max:100']);
if ($validator->fails()) {
return redirect()->back()->withErrors(['file' => 'ไฟล์จะต้องเป็น .pdf เท่านั้น'])->withInput();
}
if (Input::file('file')->isValid()) {
$filePath = date('Ymd_His') . '.pdf';
if (Input::file('file')->move(base_path() . '/public/uploads/Announces/Announce-' . $request->get('year'), $filePath)) {
//example of delete exist file
$announceList = Announce::all();
if (sizeof($announceList) != 0) {
$lastAnnounce = $announceList[sizeof($announceList) - 1];
$filename = base_path() . '/public/uploads/Announces/Announce-/' . $request->get('year') . '/' . $lastAnnounce->file_path;
if (File::exists($filename)) {
File::delete($filename);
}
// $oldAnnounce = Announce::findOrNew($lastAnnounce->id);
$lastAnnounce = DB::table('announces')->where('year', $request->get('year'))->first();
// dd($lastAnnounce);die;
if ($lastAnnounce != null) {
Announce::destroy($lastAnnounce->id);
}
}
$announce = new Announce();
$announce->file_path = $filePath;
$announce->year = $request->get('year');
$announce->save();
return redirect('/announces');
} else {
return redirect()->back()->withErrors(['error_message' => 'ไฟล์อัพโหลดมีปัญหากรุณาลองใหม่อีกครั้ง']);
}
}
}
开发者ID:nettanawat,项目名称:Sfu-laravel,代码行数:40,代码来源:AnnounceController.php
示例19: upload
public function upload($form_data)
{
$validator = Validator::make($form_data, Image::$rules, Image::$messages);
if ($validator->fails()) {
return Response::json(['error' => true, 'message' => $validator->messages()->first(), 'code' => 400], 400);
}
$photo = $form_data['file'];
$originalName = $photo->getClientOriginalName();
$originalNameWithoutExt = substr($originalName, 0, strlen($originalName) - 4);
$filename = $this->sanitize($originalNameWithoutExt);
$allowed_filename = $this->createUniqueFilename($filename);
$filenameExt = $form_data['id_auxiliar'] . $allowed_filename . '.jpg';
$uploadSuccess1 = $this->original($photo, $filenameExt);
$uploadSuccess2 = $this->icon($photo, $filenameExt);
if (!$uploadSuccess1 || !$uploadSuccess2) {
return Response::json(['error' => true, 'message' => 'Server error while uploading', 'code' => 500], 500);
}
$sessionImage = new Image();
$sessionImage->filename = $form_data['id_auxiliar'] . $allowed_filename . '.jpg';
$sessionImage->original_name = $originalName;
$sessionImage->id_catalogo_fotografia = $form_data['id_catalogo_fotografia'];
$sessionImage->id_usuario_servicio = $form_data['id_usuario_servicio'];
$sessionImage->id_auxiliar = $form_data['id_auxiliar'];
$sessionImage->estado_fotografia = 1;
$sessionImage->save();
return Response::json(['error' => false, 'code' => 200], 200);
}
开发者ID:adrianicn,项目名称:IguanaTrip,代码行数:27,代码来源:ImageRepository.php
示例20: sendEnquireMail
public function sendEnquireMail()
{
$name = Input::get('name');
$email = Input::get('email');
$mobile = Input::get('mobile');
$message2 = Input::get('message');
$result = array();
$validation = $validator = Validator::make(array('Name' => $name, 'email' => $email, 'Mobile' => $mobile, 'Message' => $message2), array('Name' => 'required', 'email' => 'required|email', 'Mobile' => 'required|numeric', 'Message' => 'required'));
if ($validation->fails()) {
$result['status'] = 'Failure';
$result['message'] = 'Fill all fields with valid values';
return response()->json($result);
}
$data['name'] = $name;
$data['email'] = $email;
$data['mobile'] = $mobile;
$data['message2'] = $message2;
Mail::send('mail.enquire', $data, function ($message1) use($data) {
$message1->from($data['email'], $data['name']);
$message1->to('[email protected]', 'Enquiry - Oxoniya')->subject('Enquiry - Oxoniya');
});
$result['status'] = 'Success';
$result['message'] = 'Contact Form Successfully Submitted';
return response()->json($result);
}
开发者ID:shayasmk,项目名称:travellocal,代码行数:25,代码来源:MailController.php
注:本文中的Illuminate\Support\Facades\Validator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论