Laravel send e-mail A to Z

Laravel send e-mail A to Z

https://ift.tt/2w6CjjC

Sending e-mail is an important part of our application. Laravel made it easy with simple e-mail sending API. You can send email from STMP, Gmail, Webmail, Mailgun, Amazon SES, SendGrid, Mailtrap and etc with the same API. If you are looking for sending an email in Laravel framework via SMTP, Gmail, Mailgun, Amazon SES, Webmail, SendGrid or any email service then this post will help you by providing the complete guide on how to send an e-mail via Laravel 6. By following this post you can do exactly the same thing in Laravel 5 or Laravel 6. By completing this post, We’ll learn below.

  • How to send test e-mail for confirming all are ok via MailTrap.
  • How to send an email with Webmail SMTP in Laravel
  • How to send an email with Gmail in Laravel
  • How to send an email with SendGrid SMTP in Laravel
  • Laravel Send Mail without a view
  • Recommendations

 

Step 01: E-mail View

We have to make an e-mail template for sending the email content to our recipients. For that, Here I’m creating a simple HTML email template in resources/views/emails/template.blade.php with the content below.

<div>
 <h3>Hi, </h3>
 <p><p> 
 </div>

Look, In this template, we will pass $name and $msgBody variable data and send it to our recipients. With this simple e-mail template, I’ll show you how to send an e-mail via Mailtrap, SMTP, Gmail, Webmail etc.

Important Note Do not pass any variable name with message. If you do then it’ll conflict and you will get an exception.

 

Step 02: Define Route

We need to define a route in web.php file for sending an e-mail. Let’s do that.

Route::get('/send-mail','HomeController@sendMail');

 

Step 03: Controller Code

Now we need to code in sendMail function for sending our email.

// HomeController.php
 
 use Illuminate\Support\Facades\Mail;
 
 public function sendMail()
 {
 $data = [
 'name'=>'Jhon Smith',
 'msgBody'=>'Welcome to Laravel Article'
 ];
 
 Mail::send('emails.template',$data,function($mail){
 $mail->from('info@example.com');
 $mail->to('jhon@example.com');
 $mail->subject('Welcome E-mail');
 });
 
 return 'Successfully send';
 }

 

First testing E-mail with MailTrap

Here first we’ll send e-mails via Test mail sending sandbox service name Mailtrap. Mailtrap is really awesome for testing email before sending with our actual email sending credentials. We are doing this for confirming that our email is sending correctly with the correct content. Sometimes from Webmail, Gmail STMP are not work as we expected for some miss-configuration. If we succeed with MailTrap then we can ensure that our sending process ok we have to focus on other things.

  • Login to Mailtrap account and goto Demo Inbox.
  • From the integrations dropdown, select laravel
  • Now copy the env configuration and paste into your env file

  mailtrap-integration.png

Now, start the server php artisan serve and hit URL http://localhost:8000/send-mail

test-email-snap.png

 

2. How to send an e-mail with Webmail SMTP in Laravel?

– Do login into cPanel and create a Webmail.

– Collect mail client configuration for your webmail.

– Update configuration in your project env file.

MAIL_DRIVER=smtp
 MAIL_HOST=mail.example.com
 MAIL_PORT=465
 MAIL_USERNAME=info@example.com
 MAIL_PASSWORD=your_webmail_password
 MAIL_FROM_ADDRESS=from@example.com
 MAIL_FROM_NAME=Example

and finally, do exactly the same as step 1, 2, 3

Now, start the server php artisan serve and hit URL http://localhost:8000/send-mail

 

3. How to send an email with Gmail in Laravel?

Important: Sending e-mail using Gmail, first you need to enable less secure apps settings from your Google Account. If you do not enable this option then you will not able to send email using Gmail from your Laravel application.

– After enabling the less secure apps option, update the env file.

MAIL_DRIVER=smtp
 MAIL_HOST=smtp.gmail.com
 MAIL_PORT=587
 MAIL_USERNAME=your_gmail_address
 MAIL_PASSWORD=your_gmail_password
 MAIL_ENCRYPTION=tls

and finally, do exactly the same described in step 1, 2, 3

Now, start the server php artisan serve and hit URL http://localhost:8000/send-mail

 

4. How to send an email with SendGrid SMTP in Laravel?

Login to your SendGrid account.

Do sender authentication from Settings > Sender Authentication

Goto Settings > API keys and Create an API key by enabling Restricted Access ( Only send email )

sendgrid-api-key.png

 

Now update the env file with configuration.

MAIL_DRIVER=smtp
 MAIL_HOST=smtp.sendgrid.net
 MAIL_PORT=587
 MAIL_USERNAME=apikey
 MAIL_PASSWORD=your_api_secret
 MAIL_ENCRYPTION=tls

N.B: Keep exactly MAIL_USERNAME=apikey

and finally, do exactly the same described in step 1, 2, 3

Now, start the server php artisan serve and hit URL http://localhost:8000/send-mail

 

5. Laravel Send Mail without a view

For sending email without view in Laravel, you have to use the raw method of Laravel Mail facade. Just follow the steps below.

– Simply define a route.

Route::get('/send-mail','HomeController@sendMail');

– Setup mail credentials in env file from one of these ( Webmail, Gmail, SendGrid, Mailtrap etc)

– Do code in the sendMail method

// HomeController.php
 
 use Illuminate\Support\Facades\Mail;
 
 public function sendMail()
 {
 
 Mail::raw('Hi, welcome to laravelarticle.com!', function ($mail) {
 $mail->from('info@example.com');
 $mail->to('jhon@example.com');
 $mail->subject('Welcome E-mail');
 });
 
 return 'Successfully send';
 }

 

Recommendations

Use your credentials in the env file only local development. On the production side, do not put credentials in the env file, keep your credentials in the config/mail.php file.

 

Hope this post will help you to send email in Laravel framework with confidently. If this post helps you to learn how to send email in Laravel framework then please share this post with others.

programming

via Laravel News Links https://ift.tt/2dvygAJ

April 2, 2020 at 08:18AM

VIDEO: High School Wrestling Champ Slams, Pins New Mexico Kidnapper

VIDEO: High School Wrestling Champ Slams, Pins New Mexico Kidnapper

https://ift.tt/3aLhfy4

A 16-year-old high school wrestler that just won a district title; well, that’s already a big man on campus. When that same teen saves the lives of three little kids, overpowering a grown man to do so? Now he just became legend. Such is the latest podium for Canaan Bower, who took on and pinned a kidnapper in Las Cruces, N.M. recently. The athlete slammed the thug to the ground, then held him until police arrived.

Coronavirus Home Defense, Home Defense Checklist, COVID-19 checklist

RELATED STORY

5 Things to Keep in Mind for Your Coronavirus Home Defense Checklist

Canaan Bower Pins  New Mexico Kidnapper

It turned out a very good thing the wrestler appeared on the scene. The attacker, 22-year-old Daniel Arroyo Beltran, allegedly assaulted a woman and her three young children. Closed circuit security footage captured the man repeatedly attempt to kidnap the three kids. When a bystander attempted to hold the door, keeping Beltran out of a convenience store where the woman and kids took refuge, Beltran forced his way in and attacked. He punched the man several times, with blood spurting to the floor.

That’s when the champion wrestler, pumping gas outside, saw the commotion and leapt into action. He ran into the store, confronted Beltran, and put his wrestling skills to work.

“So my son – who just won the wrestling district championship weeks ago – just came up behind this guy and body-slammed him and got him in a chokehold and waited for the police to show up,” Troy Bower, Canaan’s father, told lcsun-news.com.

The Dona Ana County Sheriff’s Office thanked Bower for “stepping up to save the lives of two children and potentially many others.”

Even UFC President Dan White took notice of the wrestling champ and his bravery. Noting the current coronavirus and social distancing requirements, White said he’d love to meet Bower, who he called “AWESOME!!!,” in the future.

For a wrestler, at any age, it doesn’t get much better than that.

The post VIDEO: High School Wrestling Champ Slams, Pins New Mexico Kidnapper appeared first on Personal Defense World.

guns

via Personal Defense World https://ift.tt/2Arq2GB

April 1, 2020 at 06:08AM

Introducing Metabase, a Simple and Powerful Analytics Tool

Introducing Metabase, a Simple and Powerful Analytics Tool

https://ift.tt/2X0JAfP

metabase

metabaseRecently I was looking for some simple way to analyze and create graphs from data stored in MySQL tables. I know Grafana can also plot graphs from MySQL tables, but somehow it felt like overkill and you are not using the traditional SQL syntax there. So I was searching for another solution, and it actually took me a while to find it. I might have used the wrong keywords when searching, or the SEO is not the best for this site/project, but in the end, I found Metabase.

In this blog post, I would like to highlight this open source project because I found it very simple and it does the job perfectly for what I wanted it for.

What Is Metabase?

I would describe Metabase as a tool that can provide you a graphical interface to create business intelligence and analytics graphs in minutes. It does not require any previous SQL knowledge, and it has a nice interface where you can simply make analytics with just a few clicks.

Is It Only for MySQL?

It supports a lot of backend databases:

  • MySQL
  • Postgres
  • Druid
  • SQL Server
  • Redshift
  • MongoDB
  • Google BigQuery
  • SQLite
  • H2
  • Oracle
  • Vertica
  • Presto
  • Snowflake
  • SparkSQL

Installation

It is very simple; you can just call the JAR file or run a docker container and it is done. You can run on AWS Elastic Beanstalk, or on Heroku, or even on Kubernetes.

After installation, you only have to add your datasource and you are good to go.

Creating a Graph

Using a test IMDB database, we simply graph how many movies were created per year. It takes only a few seconds and a few clicks. Of course, we can write a query by ourselves as well, and it is able to plot the result without any problems.

It Has a Lot of Features

Metabase has a lot of features and settings, but here I will just mention a few:

  • Work with large databases and configure when and how they should scan the data.
  • It can handle multiple users.
  • It can handle permissions.
  • It works with Slack and you can create questions/graphs from Slack.
  • You can create dashboards where you can add your graphs.
  • You can share dashboards and graphs.
  • Activity log
  • Alerts

Conclusion

If you are looking for a very simple data visualization or business analytics tool, I would definitely recommend taking a look at Metabase. Please let us know what you think if you are already using it!

technology

via MySQL Performance Blog https://ift.tt/1znEN8i

April 1, 2020 at 03:25PM

Take a Virtual Trip to Disney World

Take a Virtual Trip to Disney World

https://ift.tt/2R2qLVL

If, a few weeks ago, you’d told your kids that you were all going to TAKE A TRIP TO DISNEY WORLD and then added the caveat, “from the comfort of our own home,” chances are there would have been a mutiny. But, as we all know, things have changed. Standards have been lowered. Now, riding Splash Mountain from the living room couch might not seem like such a bad idea.

We’ve written before about how you can use YouTube videos to prepare kids for potentially anxiety-producing events—such as riding a rollercoaster. But you can also use those same videos to make your way across Magic Kingdom without ever needing to take a step, complain about the length of a line or manage a meltdown.

As Christina Marfice reminds us on Scary Mommy, there are entire channels on YouTube that provide videos taken by riders on Disney parks attractions:

That means anyone with a device and an internet connection can relive the magic. And it’s even better if you have a virtual reality headset or smartphone mount. Then, the videos become fully immersive experiences, basically like being back at Disneyland before the world almost totally shut down.

Is it the same as actually being on the ride? As someone who has been to Disney World a handful of times, I can categorically state that it is not. But are some of the ride videos surprisingly satisfying? They are—especially now, when the thought of being in such a germy place, among tight crowds of people, seems like such a quaint concept from a more innocent era.

So where to start? You don’t have to plan your day around your FastPass times and you can bounce back and forth across the park in mere seconds. Since I’m the one writing this and Pirates of the Caribbean is my favorite ride, let’s start there.

All those people! Touching all the surfaces! And then touching their faces with abandon! 2019 really was a simpler time. That was fun, but I’ve got Splash Mountain on the brain; let’s go there next.

If your kids like a bit of a thrill (but not too much!), the Barnstormer roller coaster is a good option. I chose this particular video because it’s a gloomy, rainy day at Disney, the park is basically deserted and it just feels … right:

If you prefer more people and more sunshine, try the Slinky Dog Dash roller coaster. Yes, I know, this ride is in an entirely different park (Hollywood Studios). Does it matter? No, it does not—there are no rules here!

Is it time for the Frozen ride, yet? Yes, I thought so. Come on, let’s head to Epcot; it’s right over here:

Okay, I wasn’t even going to click on the video for the Avatar ride (Animal Kingdom) because it’s such an incredible in-person experience that I was sure I would be disappointed. I was not. If I can’t be physically on this ride right now, at least I’ve got this:

If you haven’t had enough, the LMG Vids YouTube Channel has playlists of rides from a variety of theme parks, including all the Disney parks in Orlando and California, Legoland California, Knott’s Berry Farm, and the Tokyo and Hong Kong Disneylands.


Meet the smartest parents on Earth! Join our parenting Facebook group.

geeky,Tech,Database

via Lifehacker https://lifehacker.com

April 1, 2020 at 02:03PM

The Best String Trimmers

The Best String Trimmers

https://ift.tt/2p0nDLT

The Best String Trimmers

After using 10 string trimmers to level 12,598 square feet of an overgrown field and trimming over 6,000 linear feet along walls and fences, we’re convinced the best string trimmer (also known as a weed wacker or a weed eater) is the Ego ST1502-SF Power+ 15" String Trimmer.

technology

via Wirecutter: Reviews for the Real World https://ift.tt/2gcK1uO

March 31, 2020 at 04:22PM

5 Powerful Tools for Digital Marketing Success

5 Powerful Tools for Digital Marketing Success

https://ift.tt/2UTwaj1

Photo by Lukas Blazek on Unsplash

Today, the role of digital in your overall marketing strategy is unquestionable. Moreover, the rapid growth of digital marketing has brought with it a range of methods and solutions for making the most of what the Internet has to offer. From SEO to PPC to social, video, email, and beyond, there are more options for digital marketing now than ever before. However, utilizing them for real digital marketing success is becoming increasingly complex.

RELATED ARTICLE: DON’T LOSE YOUR STARTUP TO CHAOS

Digital Marketing Success Will Keep You Ahead of the Pack

Staying ahead of the competition is no longer something you can do alone. There’s simply too much work to do. For example, your success with digital marketing will take planning, implementing, analyzing, and improving the elements that make up your digital strategy. Therefore, to maintain a steady pace, consider utilizing these five powerful tools for digital marketing success.

Proof

The aptly named Proof uses the power of social proof messaging to boost your website’s conversion rates.

For example, Proof will send notifications, reviews, and videos to targeted customers after they leave your site. Proof works to enhance the perception of your brand. Their experts will also optimize your website design for better conversion rates. So give them a chance to help you enjoy more digital marketing success.

HubSpot

HubSpot is designed to serve as the central platform for managing your digital marketing efforts. Its tools can lead to more success online.

It offers numerous free tools for new businesses to get started with. For example, you’ll find web forms and live chat software for capturing leads. You can also make use of their basic analytics and customer relations management features without spending any money. Just imagine! More digital marketing success, for free.

However, if you want even more digital marketing success, you can have it. For example, expect some impressive marketing automation features when moving into the paid tiers. This includes integration with other software in the category. It will also help you develop a powerful tool for growing traffic, converting leads, and increasing ROI on marketing campaigns.

Plus, you’ll get help with improving close rates for deals with their effective sales tools.

SendGrid

When it comes to digital success with email marketing, a dedicated tool for creating, executing, and managing campaigns is a must. SendGrid is one of them. Its multiple features include promotional emails, automation, and design tools.

That said, its popularization has spawned a number of SendGrid alternatives that are worth looking into. This is because some of these alternatives have lower pricing tiers or longer lists of features.

So be sure to check them out before settling on a specific solution. Any one of them could lead you into more digital marketing success.

Survey Anyplace

Are you looking to improve user experience? Do you want to design a better product or learn more about your market? Or are you simply interested in having more digital marketing success overall?

Customer surveys are a great way to achieve any of these objectives. This is because Survey Anyplace aims to reduce the chances of participants abandoning your survey. They do this by helping you build simple, well-designed forms that are mobile compatible.

Yoast

This popular WordPress plugin is a handy tool for optimizing your website content search engines. Regularly updated to reflect the latest algorithms, Yoast helps you identify the best content, focus keywords, and internal links.

These optimizations will improve your rankings and give you more digital marketing success. Yoast also evaluates the readability of your pages for an additional boost.

The Right Tools Will Bring Greater Digital Marketing Success

You can build a comprehensive and successful digital marketing strategy. However, you cannot do it without the right tools.

But whether you’re looking to reduce your team’s workload with automation, gain greater insights into the effectiveness of your endeavors, or explore new avenues for marketing your business online, there’s a digital tool that can help you make it happen.

The post 5 Powerful Tools for Digital Marketing Success appeared first on Business Opportunities.

business

via Business Opportunities Weblog https://ift.tt/2CJxLjg

March 31, 2020 at 11:09AM

Apple acquires Dark Sky weather app, and that’s bad news for Android users

Apple acquires Dark Sky weather app, and that’s bad news for Android users

https://ift.tt/2WYoMG3

  • An example of Dark Sky’s maps from the desktop Web version.

  • Here’s a precipitation heatmap from the iOS version.

  • This is the main view in the iOS app.

    Dark Sky

  • And here’s the multi-day forecast in the app.

    Dark Sky

  • This push notification went out to iOS users today.

Popular weather app and data-collection service Dark Sky has been acquired by Apple for an undisclosed sum, a blog post from the Dark Sky team announced. The post claims that Dark Sky will now “reach far more people, with far more impact, than we ever could alone.”

The iOS app will not see any changes “at this time,” and it will continue to be listed on the App Store. Android and Wear OS are a different story, though. The Android app will no longer be available for download, and “service to existing users and subscribers will continue until July 1, 2020, at which point the app will be shut down.” Active subscribers will get a refund.

As for the website, which is also popular:

Weather forecasts, maps, and embeds will continue until July 1, 2020. The website will remain active beyond that time in support of API and iOS App customers.

A lot seems to be up in the air about where this will go in the long term, though. Dark Sky is notable in part for its big data-driven Dark Sky Forecast API, which provides customers with hyper-local weather data for use in their own apps or services. That API will no longer accept new signups, though “service for existing customers is not changing today.” The API will function for existing customers through the end of 2021.

That API and the related data operation may be the main reason Apple was interested in Dark Sky; the service is known for providing smart notifications and highly localized data about precipitation, among other things, in much more detail than Apple’s own Weather app.

The blog post also notes that Dark Sky will now be subject to Apple’s privacy policy, and the app’s developer is already listed as “Apple” in the App Store.

Listing image by Dark Sky

geeky

via Ars Technica https://arstechnica.com

March 31, 2020 at 03:37PM

The Best External Optical Drives for DVDs and Blu-rays

The Best External Optical Drives for DVDs and Blu-rays

https://ift.tt/2xOwBSg

The Best External Optical Drives for DVDs and Blu-rays

Modern laptops rarely include optical drives for CDs, DVDs, or Blu-rays, and music and video streaming services make it so you never need to play a disc if you don’t want to. But if you have decades’ worth of CDs, DVDs, or Blu-rays to watch, or home movies to archive, the Asus ZenDrive U9M is the best USB DVD burner, and LG’s BP60NB10 is the best Blu-ray burner. Both drives are quick to rip data from discs to your computer or to burn new discs with your own data, and both work with PCs and Macs and are reasonably priced.

technology

via Wirecutter: Reviews for the Real World https://ift.tt/2gcK1uO

March 31, 2020 at 03:38PM

Laravel Validation 101, Controllers, Form Requests, and Rules

Laravel Validation 101, Controllers, Form Requests, and Rules

https://ift.tt/3bCoetp

Laravel Validation 101, Controllers, Form Requests, and Rules

A core part of any project is understanding how to validate the incoming request from your users and in this tutorial let’s look at how we can setup validation with our controllers, form requests, and rules.

Working with Controllers

By default, all Laravel controllers that extend from the Base Controller inherit the ValidatesRequests trait.

The ValidatesRequests trait gives you access to the validate method in your controller methods.

For example, say the user is creating an Article:

They may be entering a name, and some content for this article, along with a date to publish. Your controller validation may look like one of these, which are all valid:

public function store(Request $request) { $this->validate($request, [ 'name' => 'required|string', 'body' => 'required|string', 'publish_at' => 'required|date_format:Y-m-d H:i:s' ]); // The request validated and this code will get run ... } public function store(Request $request) { // Note: the array syntax is also available $request->validate([ 'name' => ['required', 'string'], 'body' => ['required', 'string'], 'publish_at' => ['required', 'date_format:Y-m-d H:i:s'], ]); // The request validated and this code will get run ... } public function store() { request()->validate([ // Validation Rules... ]); // The request validated and this code will get run ... } public function store() { $this->validate(request(), [ // Validation Rules... ]); // The request validated and this code will get run ... } 

It should also be noted, that the response to the validate method will be the data that was validated:

public function store(Request $request) { $validatedData = $request->validate([ 'name' => ['required', 'string'], 'body' => ['required', 'string'], 'publish_at' => ['required', 'date_format:Y-m-d H:i:s'], ]); // I know that the only keys in validated data are the ones that were successfully validated, i.e.: name, body, published_at $this->articleService->store($validatedData); } 

Alternatively, you can do this too:

public function store(Request $request) { $request->validate([ 'name' => ['required', 'string'], 'body' => ['required', 'string'], 'publish_at' => ['required', 'date_format:Y-m-d H:i:s'], ]); // I know that the only keys in validated data are the ones that were successfully validated, i.e.: name, body, published_at $this->articleService->store($request->only('name', 'body', 'published_at')); } 

A list of the available validation rules can be found here.

Working with Form Requests

If you would like to extract your validation logic away from your controllers, or you would like to do authorization and validation at the same time, Laravel makes the Form Request class available to you.

You can make a form request class using one of the many built-in Laravel generators:

php artisan make:request StoreArticleRequest 

This will make you the following class in app/Http/Requests by default:

class StoreArticleRequest extends FormRequest { public function authorize() { return true; } public function rules() { return [ // ]; } } 

Form request classes comes with 2 methods, authorize and rules.

Authorize

Authorize lets you prevent the controller code from running if this method returns false. Laravel will throw a 401 unauthorized exception.

An example usage might be:

public function authorize() { return $this->user()->can('create articles'); } 

Rules

The rules method will return our array of rules that was in our controller validate method;

public function rules() { return [ 'name' => ['required', 'string'], 'body' => ['required', 'string'], 'publish_at' => ['required', 'date_format:Y-m-d H:i:s'], ]; } 

Note: You can type-hint any dependencies needed into the rules method.

So, how do we use this class? We type-hint it right into our controller method:

public function store(StoreArticleRequest $request) { // Validation and Rules passed } 

If the validation fails, the user will be redirected back with the errors flashed to the session. If it is an AJAX call, it will be a 422 Unprocessable Entity response.

You may get the validated data just like before:

public function store(StoreArticleRequest $request) { $validatedData = $request->validated(); // Insert into database ... } 

Working with Custom Rule Classes

If there is a validation rule that does not exist as part of the available built-in validation rules, you can create a custom one:

Again, using one of Laravel’s make commands:

php artisan make:rule IsValidStateInUSA 

This will make you the following class in app/Rules by default:

class IsValidStateInUSA implements Rule { public function passes($attribute, $value) { // } public function message() { return 'The validation error message.'; } } 

Your passes method holds the logic for allowing this validation method through. The message method is the message that gets returned if it fails.

Using the example of Is a valid State in the USA, we would need the item passed in to be one of 50 different state codes. It could look like this:

class IsValidStateInUSA implements Rule { public function passes($attribute, $value) { return in_array(strtoupper($value), [ 'AL', 'AK', 'AZ', ... ]); } public function message() { return 'This is not a valid state code in the USA.'; } } 

Then, to use this in your controller or form request, you just add it to the list of validation rules for that key:

public function store(Request $request) { $request->validate([ 'state' => ['required', new IsValidStateInUSA], ]); ... } 

Handling Validation Errors

When validation fails, Laravel will automatically redirect back, with an $errors variables flashed in the session.

You can easily create a file called messages.blade.php and include in your master layout file like this:

@if($errors->any()) <div class="alert alert-danger" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> @foreach($errors->all() as $error) <br/> @endforeach </div> @endif 

Which will display all errors flashed to the session, or if you prefer to handle them one by one on a per blade file basis, you can use the blade @error helper:

@error('title') <div class="alert alert-danger"></div> @enderror 

The $message variable will be provided to you inside the @error tag.

Customizing Error Messages

When working with the validate method, you can override the messages with the third parameter:

public function store(Request $request) { $this->validate($request, [ 'name' => 'required|string', 'body' => 'required|string', 'publish_at' => 'required|date_format:Y-m-d H:i:s' ], [ 'name.required' => 'A article name is required', 'body.required' => 'A article body is required', 'publish_at.date_format' => 'The publish at date is not in the correct format.' ]); // The request validated and this code will get run ... } 

When working with a form request class, a messages function can also be implemented to customize the error message for each specific rule:

public function messages() { return [ 'name.required' => 'A article name is required', 'body.required' => 'A article body is required', 'publish_at.date_format' => 'The publish at date is not in the correct format.' ]; } 

For the most up to date documentation and a much more in-depth look at validation, visit the Laravel Documentation.

Filed in: News

programming

via Laravel News https://ift.tt/14pzU0d

March 31, 2020 at 09:02AM