title: How to destroy a record using a form in Laravel and display status?
body: <p>I'm using Laravel and I am currently implementing the 'destroy' method in a resource controller as part of CRUD. The method should delete the specified record in my database.</p>
  <p>The method is called by my blade.php file, which uses a form with the DELETE method and <code>route('my-resources.destroy', $my-resource-&gt;id)</code>. I want the controller to return a string such as 'Deleted successfully!' so that I can display that to the client.</p>
  <p>Here is my code:</p>
  <p>In views/book/edit.blade.php:</p>
  <pre><code>&lt;form method=&quot;DELETE&quot; action=&quot;{{ route('books.destroy', $book-&gt;id) }}&quot;&gt;
      &lt;div class=&quot;form-item center&quot;&gt;
          &lt;button type=&quot;submit&quot; class=&quot;btn-danger&quot;&gt;Delete&lt;/button&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  <p>and in BookController.php:</p>
  <pre><code>public function destroy($id)
      {
          $book = Book::find($id);
          $book-&gt;delete();
  
          return redirect()-&gt;away('https://www.google.com');
      }
  </code></pre>
  <p>I put a redirect to google.com just to see if the redirect works, but it doesn't. When I click the 'Delete' button, the url changes from <code>http://127.0.0.1:8000/books/1/edit</code> to <code>http://127.0.0.1:8000/books/1?</code> with that question mark at the end. What am I doing wrong?</p>
  <p>I have another question: if I want to return the status, should I use something like</p>
  <pre><code>Route::get('/', function () {
      return 'Deleted successfully';
  });
  </code></pre>
  <p>or</p>
  <pre><code>$request-&gt;session()-&gt;flash('status', 'Task was successful!');
  /** and some random return statement **/
  </code></pre>
  <p>Thanks!</p>