title: set input to empty string or null if it is not filled and save other datas in vue with laravel
body: <p>I have about seven input field in my newinsight i want some of the input field to be optional either it is field or not the post should be saved to database, i get error 500 if i leave some inputs empty. I have tried an it seems not working can anyone help out. below is my code.</p>
  <p><strong>my controller</strong></p>
  <pre><code>public function store(Request $request)
  {
      $insight= new Insight();
      $insight-&gt;slug = $request-&gt;slug;
      $insight-&gt;body = $request-&gt;body;
      $insight-&gt;head1 = $request-&gt;head1;
      $insight-&gt;paragraph1 = $request-&gt;paragraph1;
      $insight-&gt;head2 = $request-&gt;head2;
      $insight-&gt;paragraph2 = $request-&gt;paragraph2;
      $insight-&gt;head3 = $request-&gt;head3;
      $insight-&gt;paragraph3 = $request-&gt;paragraph3;
      $insight-&gt;head4 = $request-&gt;head4;
      $insight-&gt;paragraph4 = $request-&gt;paragraph4;
      $insight-&gt;head5 = $request-&gt;head5;
      $insight-&gt;paragraph5 = $request-&gt;paragraph5;
      $insight-&gt;head6 = $request-&gt;head6;
      $insight-&gt;paragraph6 = $request-&gt;paragraph6;
      $insight-&gt;head7 = $request-&gt;head7;
      $insight-&gt;paragraph7 = $request-&gt;paragraph7;
      if($request-&gt;hasFile('image')){
          $file = $request-&gt;file('image');
         $file_name = time(). '.' . $file-&gt;getClientOriginalName();
         $file-&gt;move(public_path('img/'),$file_name);
         $insight-&gt;image = 'img/' . $file_name;
         
      }
    
      $insight-&gt;save();
      return response()-&gt;json(['message'=&gt;'Saved Successfully'],200); 
  }
  </code></pre>
  <p><strong>form</strong></p>
  <pre><code> data() {
          return {
              form: new Form({
               image:null,
               slug:'',
               body: '',
               head1:'',
               paragraph1: '',
               head2:'',
               paragraph2: '',
               head3:'',
               paragraph3: '',
               head4:'',
               paragraph4: '',
               head5:'',
               paragraph5: '',
               head6:'',
               paragraph6: '',
               head7:'',
               paragraph7: '',
              }),
             show: false
          }
      },
      methods: {
          onChange(e){
             const file = e.target.files[0]
             this.form.image = file
              console.log(&quot;selected file&quot;, file) 
          },
          submit(){
              this.form.post('/api/insight', {
                  transfromRequest: [function(data, headers){
                      return objectToFormData(data)
                  }],
                  onUploadProgress: e =&gt;{
                      console.log(e,)
                  }
              }).then(({data})=&gt;{
                  console.log(data)
              })
              console.log(this.form)
               this.form = ''
               this.form.image = ''
          },
  </code></pre>
  <p>above is my vue js form</p>