title: Data not inserted in database using laravel 8
body: <p>I'm trying to save data from a form modal to database .</p>
  <p>So , I'm using the following code :</p>
  <p>Controller :</p>
  <pre><code>  public function store(Request $request)
  {
  
     if ($files = $request-&gt;file('casting_photo'))
  
      {
    
         $destinationPath = public_path('public/castingimages'); // upload path         
         $profileImage = date('YmdHis') . &quot;.&quot; . $files-&gt;getClientOriginalExtension();
         $files-&gt;move($destinationPath, $profileImage);
        
              $cast = new Casting;
  
              $cast -&gt; casting_name= $request-&gt;input('casting_name');
              $cast -&gt; casting_cin= $request-&gt;input('casting_cin');
              $cast -&gt; casting_email= $request-&gt;input('casting_email');
              $cast -&gt; casting_phone= $request-&gt;input('casting_phone');  
              $cast -&gt; casting_gender= $request-&gt;input('casting_gender');
              $cast -&gt; casting_address= $request-&gt;input('casting_address');
              $cast -&gt; casting_city= $request-&gt;input('casting_city');
              $cast-&gt; casting_photo=$profileImage;
  
                $cast-&gt;save();
  
      }
      
  }
  </code></pre>
  <p>View :</p>
  <pre><code>   &lt;x-app-layout&gt;
      &lt;div class=&quot;container-fluid&quot;&gt;
        &lt;div class=&quot;row&quot;&gt;
          &lt;div class=&quot;col app-col&quot;&gt;
            &lt;div class=&quot;mb-2&quot;&gt;
              &lt;h1&gt;Castings&lt;/h1&gt;
  
              &lt;div class=&quot;top-right-button-container&quot;&gt;
                &lt;button type=&quot;button&quot; data-target=&quot;#castingmodel&quot; data-toggle=&quot;modal&quot; class=&quot;btn btn-outline-primary btn-lg top-right-button  mr-1&quot;&gt;Add New
  &lt;/button&gt;
                &lt;div class=&quot;col-xl-6&quot;&gt;
                  &lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;/div&gt;
              &lt;div class=&quot;separator mb-5&quot;&gt;&lt;/div&gt;
            &lt;/div&gt;
         
        &lt;/div&gt;
      &lt;/div&gt;
  
  
  
   &lt;div class=&quot;modal fade&quot; id=&quot;castingmodel&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-hidden=&quot;true&quot;&gt;
          &lt;div class=&quot;modal-dialog&quot; role=&quot;document&quot;&gt;
            &lt;div class=&quot;modal-content&quot;&gt;
              &lt;div class=&quot;modal-header&quot;&gt;
                &lt;h5 class=&quot;modal-title&quot; id=&quot;exampleModalContentLabel&quot;&gt;New message&lt;/h5&gt;
                &lt;button type=&quot;button&quot; class=&quot;close&quot; data-dismiss=&quot;modal&quot; aria-label=&quot;Close&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;&amp;times;&lt;/span&gt;&lt;/button&gt;
              &lt;/div&gt;
      &lt;form method=&quot;post&quot;  class=&quot;needs-validation tooltip-label-right&quot; id=&quot;formcast&quot; novalidate enctype=&quot;multipart/form-data&quot;&gt;
          {{ csrf_field() }}
              &lt;div class=&quot;modal-body&quot;&gt;
                  &lt;input type=&quot;hidden&quot; id=&quot;id_hidden&quot; name=&quot;id&quot; /&gt;
  
                  &lt;div class=&quot;form-group position-relative error-l-50&quot;&gt;
                    &lt;label&gt;Name&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name =&quot;casting_name&quot; id=&quot;casting_name&quot; &gt;
                    &lt;div class=&quot;invalid-tooltip&quot;&gt;Name is required!&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group position-relative error-l-50&quot;&gt;
                    &lt;label&gt;CIN&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; name=&quot;casting_cin&quot; id=&quot;casting_cin&quot; required&gt;
                    &lt;div class=&quot;invalid-tooltip&quot;&gt;CIN is required!&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group position-relative error-l-50&quot;&gt;
                    &lt;label&gt;EMAIL&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; rows=&quot;2&quot; name=&quot;casting_email&quot; required&gt;
                    &lt;div class=&quot;invalid-tooltip&quot;&gt;EMAIL is required!&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group position-relative error-l-50&quot;&gt;
                    &lt;label&gt;PHONE&lt;/label&gt;
                    &lt;input type=&quot;number&quot; class=&quot;form-control&quot; rows=&quot;2&quot; name=&quot;casting_phone&quot; required&gt;
                    &lt;div class=&quot;invalid-tooltip&quot;&gt;PHONE is required!&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group position-relative&quot;&gt;
                    &lt;label&gt;Radio&lt;/label&gt;
                    &lt;div&gt;
                      &lt;div class=&quot;custom-control custom-radio&quot;&gt;
                        &lt;input type=&quot;radio&quot; id=&quot;jQueryCustomRadio1&quot; name=&quot;casting_gender&quot;  class=&quot;custom-control-input&quot; required value=&quot;homme&quot;&gt;
                        &lt;label class=&quot;custom-control-label&quot; for=&quot;jQueryCustomRadio1&quot;&gt;Homme&lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class=&quot;custom-control custom-radio&quot;&gt;
                        &lt;input type=&quot;radio&quot; id=&quot;jQueryCustomRadio2&quot; name=&quot;casting_gender&quot; class=&quot;custom-control-input&quot; required value=&quot;femme&quot;&gt;
                        &lt;label class=&quot;custom-control-label&quot; for=&quot;jQueryCustomRadio2&quot; &gt;Femme&lt;/label&gt;
                      &lt;/div&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group position-relative error-l-50&quot;&gt;
                    &lt;label&gt;ADDRESS&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; rows=&quot;2&quot; name=&quot;casting_address&quot; required&gt;
                    &lt;div class=&quot;invalid-tooltip&quot;&gt;ADDRESS is required!&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;form-group position-relative error-l-50&quot;&gt;
                    &lt;label&gt;CITY&lt;/label&gt;
                    &lt;input type=&quot;text&quot; class=&quot;form-control&quot; rows=&quot;2&quot; name=&quot;casting_city&quot; required&gt;
                    &lt;div class=&quot;invalid-tooltip&quot;&gt;CITY is required!&lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class=&quot;input-group mb-3&quot;&gt;
                    &lt;div class=&quot;input-group-prepend&quot;&gt;
                      &lt;span class=&quot;input-group-text&quot;&gt;Upload&lt;/span&gt;
                    &lt;/div&gt;
                    &lt;div class=&quot;custom-file&quot;&gt;
                      &lt;input type=&quot;file&quot; name=&quot;casting_photo&quot; class=&quot;custom-file-input&quot; id=&quot;inputGroupFile01&quot;&gt;
                      &lt;label class=&quot;custom-file-label&quot; for=&quot;inputGroupFile01&quot;&gt;Choose file&lt;/label&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
  
                  &lt;button type=&quot;submit&quot; id=&quot;createBtn&quot; class=&quot;btn btn-primary&quot;&gt;Save&lt;/button&gt;
  
                  &lt;div class=&quot;result&quot;&gt;&lt;/div&gt;
             
              &lt;/div&gt;
  
                 &lt;/form&gt;
            &lt;/div&gt;
          &lt;/div&gt; 
        &lt;/div&gt;
  
  
  
  
   &lt;script
    src=&quot;https://code.jquery.com/jquery-3.6.0.js&quot;
    integrity=&quot;sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=&quot;
    crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot; integrity=&quot;sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js&quot; integrity=&quot;sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt;
  
  
  
  &lt;script type=&quot;text/javascript&quot;&gt;
  
       $(document).ready(function(){
  
  
          $('#formcast').on('submit', function(e){
              e.preventDefault();
  
              $.ajax({
                  type: &quot;POST&quot;,
                  url:&quot;castings&quot;,
                  data : $('#formcast').serialize(),
                  success: function(response){
                      console.log(response)
                      $('#castingmodel').modal('hide')
                      alert(&quot;Data saved&quot;);
                  },
                  error: function(error){
                      console.log(error)
                      alert(&quot;Data not saved&quot;);
                  }
              });
          });
       });
   
  &lt;/script&gt;
  &lt;/x-app-layout&gt;
  </code></pre>
  <p>It doesn't show any error and the data is not inserted into the database.</p>
  <p>I checked the file <code>.env</code> the parameters of the database are correct.</p>
  <p>I don't know if it is because of the input file that I'm uploading in the form</p>