title: Beginner in Laravel Delete data using modal
body: <p>My modal works so well and can delete data but not the exact id that i selected to delete like example id: 1, 2, 3, 4 and i will select id: 4 but the id: 4 will not delete the id deleted is id: 1</p>
  <p>this is my delete function inside AllSystemController</p>
  <pre><code>public function deletestorydata($id)
  {
      $story = Story::findOrFail($id);
      $story-&gt;delete();
      return redirect()-&gt;back()-&gt;with('success', 'Data has successfully deleted.');
  }
  </code></pre>
  <p>and this is my route web.php in story section</p>
  <pre><code>Route::get('stories/table', 'AllSystemController@indexstoriesdata')-&gt;name('stories.table');
  Route::get('/stories/add', 'AllSystemController@createviewstories')-&gt;name('create.stories');
  Route::post('/stories/storiesdata/submit', 'AllSystemController@submitstories')-&gt;name('submit.stories.data');
  Route::get('/stories/view/{id}', 'AllSystemController@showviewstories')-&gt;name('view.story.data');
  Route::get('/stories/edit/{id}', 'AllSystemController@editviewstories')-&gt;name('edit.stories');
  Route::patch('/stories/{id}', 'AllSystemController@updatestorydata')-&gt;name('update.story.data');
  Route::delete('/deletestory/{id}', 'AllSystemController@deletestorydata')-&gt;name('delete.story.data');
  </code></pre>
  <p>and this is my view  index_stories_data.blade.php</p>
  <pre><code>&lt;table id=&quot;table-style-hover&quot; class=&quot;table table-striped table-hover table-bordered nowrap&quot;&gt;
  &lt;thead&gt;
  &lt;tr&gt;
      &lt;th width=&quot;1%&quot;&gt;Image&lt;/th&gt; 
      &lt;th&gt;Title&lt;/th&gt;
      &lt;th&gt;Flagship&lt;/th&gt;
      &lt;th&gt;Category&lt;/th&gt;
      &lt;th&gt;Author&lt;/th&gt;
      &lt;th class=&quot;text-center&quot;&gt;Action&lt;/th&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  @foreach($story as $row)
  &lt;tr&gt;
      &lt;td&gt;&lt;img src=&quot;{{ asset('storage/stories_images')}}/{{$row-&gt;display_image}}&quot; class=&quot;img-thumbnail&quot; width=&quot;50&quot;&gt;&lt;/td&gt;
      &lt;td&gt;{{$row-&gt;title}}&lt;/td&gt;
      &lt;td&gt;{{$row-&gt;is_flagship}}&lt;/td&gt;
      &lt;td&gt;{{$row-&gt;category_name}}&lt;/td&gt;
      &lt;td&gt;{{$row-&gt;name}}&lt;/td&gt;
      &lt;td&gt;
      &lt;div class=&quot;dropdown&quot;&gt;
         &lt;button class=&quot;btn btn-primary&quot; type=&quot;button&quot; id=&quot;dropdownMenuButton&quot; data-toggle=&quot;dropdown&quot; aria-haspopup=&quot;true&quot; aria-expanded=&quot;false&quot;&gt;Action&amp;nbsp;&lt;i class=&quot;fa fa-sort-desc&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;&lt;/button&gt;
    &lt;div class=&quot;dropdown-menu&quot; aria-labelledby=&quot;dropdownMenuButton&quot;&gt;
      &lt;a style=&quot;color:black; font-weight: bold;&quot; class=&quot;dropdown-item&quot; href=&quot;{{url('/stories/view', $row-&gt;id)}}&quot; target=&quot;_blank&quot;&gt;View&lt;/a&gt;
      &lt;a style=&quot;color:black; font-weight: bold;&quot; class=&quot;dropdown-item&quot; href=&quot;{{url('/stories/edit', $row-&gt;id)}}&quot; target=&quot;_blank&quot; class=&quot;btn btn-primary&quot;&gt;Edit&lt;/a&gt;
      &lt;a style=&quot;color:black; font-weight: bold;&quot; class=&quot;dropdown-item&quot; data-toggle=&quot;modal&quot; data-target=&quot;#delete&quot; href=&quot;&quot;&gt;Delete&lt;/a&gt;
  
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
    
  
  <p>this is my modal and script</p>
  <pre><code>&lt;div class=&quot;modal fade modal-icon&quot; id=&quot;delete&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria- 
  labelledby=&quot;myModalLabel&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;h4 class=&quot;modal-title&quot; id=&quot;myModalLabel&quot;&gt;Delete Confirmation&lt;/h4&gt;
  &lt;/div&gt;
  &lt;form method=&quot;post&quot; class=&quot;delete_form&quot; action=&quot;{{url('/deletestory', $row-&gt;id)}}&quot;&gt;
      {{csrf_field()}}
      &lt;input type=&quot;hidden&quot; name=&quot;_method&quot; value=&quot;DELETE&quot;&gt;
  &lt;div class=&quot;modal-body&quot;&gt;
    &lt;h4 class=&quot;text-center&quot;&gt;Are you sure you want to delete it?&lt;/h4&gt;
  &lt;/div&gt;
  
  &lt;div class=&quot;modal-footer&quot;&gt;
  &lt;button type=&quot;button&quot; class=&quot;btn btn-process&quot; data-dismiss=&quot;modal&quot;&gt;Cancel&lt;/button&gt;
  &lt;button type=&quot;submit&quot; class=&quot;btn btn-danger&quot;&gt;Confirm&lt;/button&gt;
  &lt;/form&gt;
  
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script&gt;
    $(document).ready(function(){
      $('.delete_form').on('delete', function(){
        if(confirm(&quot;Are you sure you want to delete this data?&quot;))
        {
          return true;
        }
        else
        {
          return false;
        }
      });
    });
  &lt;/script&gt;
  @endforeach
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  <p>and i tried to dd($story); value, example id: 1, 2, 3, 4, and i will select button to delete is id: 3 and the result in dd is id: 1 is there something wrong to my function? how can i fix this?</p>