title: Creating a preview page feature in Laravel 5.1
body: <p>I am new to Laravel and I am creating content management system as practice to get familiar with the framework. Currently, I am working on the feature for the user to preview the information they have entered for updating the new page they want to create and here is code for the view:</p>
  
  <pre><code>&lt;div ng-controller="PagesController"&gt;
  &lt;form action="{{url('admin/page/preview')}}" method="post" name="pageForm"&gt;
      &lt;div class="col-md-9"&gt;
          &lt;div class="panel-body"&gt;
              &lt;div class="row"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label&gt;Title&lt;/label&gt;
                      &lt;input type="hidden" name="_token" value="{{ csrf_token() }}"&gt;
                      &lt;input type="text" class="form-control input-md" name="title" ng-model="page.title"&gt;
                   &lt;/div&gt;
                      &lt;!-- &lt;input type="submit" value="Preview"&gt; --&gt;
                &lt;/div&gt;
  
              &lt;div class="row"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;fieldset style="border: 1px solid #E4E4E4; padding-top: 5px; padding-bottom: 5px;"&gt;
                      &lt;div class="form-group"&gt;
                          &lt;div class="col-md-5"&gt;
                              &lt;label&gt;Add File&lt;/label&gt;
                              &lt;input type="file" name="upload" nv-file-select uploader="updateUploader" value="Select Picture" ng-model="page.upload" &gt;
                          &lt;/div&gt;
  
                          &lt;div class="col-md-6"&gt;
                              &lt;table class="table"&gt;
                                  &lt;thead&gt;
                                      &lt;tr&gt;
                                          &lt;th&gt;Name&lt;/th&gt;
                                          &lt;th&gt;Progress&lt;/th&gt;
                                          &lt;th&gt;Actions&lt;/th&gt;
                                      &lt;/tr&gt;
                                  &lt;/thead&gt;
                                  &lt;tbody&gt;
                                      &lt;tr ng-repeat="item in updateUploader.queue"&gt;
                                          &lt;td style="max-width: 170px; word-wrap: break-word;" ng-cloak&gt;&lt;strong&gt;@{{ item.file.name}}&lt;/strong&gt;&lt;/td&gt;
                                          &lt;td&gt;&lt;div class="col-md-12"&gt;&lt;progressbar value="item.progress"&gt;&lt;/progressbar&gt;&lt;/div&gt;&lt;/td&gt;
                                          &lt;td nowrap ng-cloak&gt;
                                          &lt;button type="button" class="btn btn-danger btn-xs" ng-click="item.remove()"&gt;
                                              &lt;span class="glyphicon glyphicon-trash"&gt;&lt;/span&gt; Remove
                                          &lt;/button&gt;
                                          &lt;/td&gt;
                                      &lt;/tr&gt;
                                  &lt;/tbody&gt;
                              &lt;/table&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/fieldset&gt;
                  &lt;/div&gt;
              &lt;/div&gt;&lt;br&gt;
  
              &lt;div class="row"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label&gt;Body&lt;/label&gt;
                      &lt;input type="hidden"  name="body" value="@{{page.body}}"/&gt;
                      &lt;summernote  name="body" ng-model="page.body" config="options" height="300"&gt;&lt;/summernote&gt;
  
                      &lt;div ng-messages="pageForm.body.$error" ng-if="pageForm.body.$dirty"&gt;
                          &lt;div ng-message="required"&gt;
                              &lt;span class="error-msgs"&gt;Please enter page information&lt;/span&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
              &lt;br/&gt;
              &lt;div class="row"&gt;
              &lt;div class="form-group"&gt;
                  &lt;div class="col-md-12 text-left"&gt;
  
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;/div&gt;
              &lt;div class="row"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;div class="checkbox col-md-12 text-left"&gt;
                          &lt;label&gt;&lt;input type="checkbox" value="" ng-model"page.serivice" ng-false-value="0" ng-true-value="1" &gt;&lt;strong&gt;Update page to services&lt;/strong&gt;&lt;/label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="row"&gt;
                 &lt;div class="form-group"&gt;
                  &lt;div class="col-md-12 text-left"&gt;
                     &lt;button type="button" class="btn btn-success" name="update" ng-disabled="pageForm.$invalid" ng-click="update()"&gt;Update&lt;/button&gt;
                     &lt;input type="submit" class="btn btn-default btn-md" value="Preview"&gt;
                   &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
  
          &lt;div class="col-md-3"&gt;
          &lt;div class="panel panel-default general-panel publish" style="margin-top: 35px;"&gt;
              &lt;div class="panel-heading"&gt;
                  &lt;div class="title"&gt;Navigation&lt;/div&gt;
              &lt;/div&gt;
              &lt;div class="panel-body"&gt;
                  &lt;span class=""&gt;
                      &lt;i&gt;&lt;/i&gt;&lt;strong&gt;Parent pages&lt;/strong&gt;&amp;nbsp;
                      &lt;div class="btn-group"&gt;
                          &lt;select class="form-control" name="publish_period" ng-model="page.parent_nav"&gt;
                              &lt;option value=""&gt;No Parent Navigation&lt;/option&gt;
                              &lt;option value="about-us"&gt;About Us&lt;/option&gt;
                              &lt;option value="media"&gt;Media&lt;/option&gt;
                              &lt;option value="publication"&gt;Publication&lt;/option&gt;
                              &lt;option value="law"&gt;Law&lt;/option&gt;
                              &lt;option value="legislation"&gt;Legislation&lt;/option&gt;
                              &lt;option value="compliance"&gt;Compliance&lt;/option&gt;
                              &lt;option value="license"&gt;Applying For License&lt;/option&gt;
                          &lt;/select&gt;
                      &lt;/div&gt;&lt;br&gt;&lt;br&gt;
                  &lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
              &lt;div class="panel panel-default general-panel general-summary"&gt;
          &lt;div class="panel-body"&gt;
              &lt;table class="table"&gt;
                  &lt;thead&gt;
                      &lt;tr&gt;
                          &lt;th colspan="3"&gt;&lt;h5&gt;Uploaded Documents&lt;/h5&gt;&lt;/th&gt;
                      &lt;/tr&gt;
                  &lt;/thead&gt;
                  &lt;tbody&gt;      
                  &lt;tr ng-repeat="document in documents"&gt;
                      &lt;td style="max-width: 100px; word-wrap: break-word;"&gt;@{{document.file_path}}&lt;/td&gt;
                      &lt;td&gt;
                         &lt;a href="{{ url('admin/downloadfile') }}/@{{document.id}}" target="_blank"&gt;&lt;i class="fa fa-download fa-fw"&gt;&lt;/i&gt;Download&lt;/a&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
           &lt;/div&gt;
         &lt;/div&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the code for the route for previewing the page:</p>
  
  <pre><code>  Route::post('page/preview','PagesController@preview');
  </code></pre>
  
  <p>and the controller method for the preview function:</p>
  
  <pre><code>public function preview(Request $request)
  {
  
     return view('admin.pages.preview')-&gt;with('title',$request-&gt;input('title'))-&gt;with('body',$request-&gt;input('body'));
  }
  </code></pre>
  
  <p>This works for me, but when I refreshed the preview page it would generate an error saying BadMethodCallException. So I am wondering how can eliminate this from happening? and thanks in advance.</p>