title: Show duplicate entry warning in laravel
body: <p>how to display duplicate entry warning error to my view in laravel blade. so when they key in same name the warning will appear when they saved it.</p>
  
  <p>Note: i have already make my Schema  $table->string('studentname')->unique();;</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function store(Request $request)
  {
      $this-&gt;validate($request, [
          'studentname'=&gt;'required|max:50',
      ]);   
      $students = new Student();
      $students-&gt;studentname = $request-&gt;studentname;
      $students-&gt;address = $request-&gt;address;
      $students-&gt;religion = $request-&gt;religion;
      $students-&gt;save();
  
      return redirect()-&gt;route('students.index')
          -&gt;with('flash_message', 'Success.');
  }
  </code></pre>
  
  <p><strong>View-Blade</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
    &lt;h1 class="well"&gt;Registration Form&lt;/h1&gt;
    &lt;div class="col-lg-12 well"&gt;
      &lt;div class="row"&gt;
        &lt;form action="{{route('students.store')}}" method="POST"&gt;
          {{csrf_field()}}
          &lt;div class="col-sm-12"&gt;
            &lt;h3&gt;CHILD'S INFORMATION&lt;/h3&gt;
            &lt;hr&gt;
            &lt;div class="row"&gt;
              &lt;div class="col-sm-4 form-group"&gt;
                &lt;label&gt;FULLNAME&lt;/label&gt;
                &lt;input type="text" name="studentname" value="" placeholder="Enter FULLNAME.." class="form-control" required&gt;
              &lt;/div&gt;  
              &lt;div class="col-sm-4 form-group"&gt;
                &lt;label&gt;RELIGION&lt;/label&gt;
                &lt;input type="text" name="religion" value="" placeholder="Enter RELIGION.." class="form-control"&gt;
              &lt;/div&gt;
              &lt;div class="col-sm-4 form-group"&gt;
                &lt;label&gt;ADDRESS&lt;/label&gt;
                &lt;input type="text" name="address" value="" placeholder="Enter ADDRESS.." class="form-control"&gt;
              &lt;/div&gt;
              &lt;div&gt;    
                &lt;button type="submit" class="btn btn-default"&gt;SUBMIT&lt;/button&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>