title: How to delete data from database in Laravel 8.*
body: <p>I'm trying to delete city from my db but i really got no clue what to do next.
  Since I didnt find anything about deleteing data from db for Laravel 8.* I think this might be usefull for other stackoverflowers too.</p>
  <p>My <strong>error</strong> says clearly that I'm missing some arguments,</p>
  <pre><code>Too few arguments to function App\Http\Controllers\CityController::delete(), 0 passed in C:\xampp\htdocs\Laravel1\vendor\laravel\framework\src\Illuminate\Routing\Controller.php on line 54 and exactly 1 expected
  </code></pre>
  <p>While my controller says that he expected type 'object' but only found array</p>
  <pre><code>Exoected type 'object'. Found 'array'. intelephense(1006)
  @var array $todelete
  </code></pre>
  <p><strong>Here is Route from web.php</strong></p>
  <pre><code>Route::delete('cities', [App\Http\Controllers\CityController::class, 'delete'])-&gt;name('cities.delete');
  </code></pre>
  <p>And this is form I'm using to delete</p>
  <pre><code>&lt;form class=&quot;float-right m-0&quot; method=&quot;post&quot; action=&quot;{{ route('cities.delete') }}&quot;&gt;
                                  @method('delete')
                                  @csrf
                                  &lt;div class=&quot;form-row&quot;&gt;
                                      &lt;input type=&quot;hidden&quot; name=&quot;cityId&quot; value=&quot;{{ $city-&gt;id }}&quot;&gt;
                                      &lt;button&gt; &lt;i class=&quot;fa fa-trash-alt&quot;&gt;&lt;/i&gt;&lt;/button&gt;
                                  &lt;/div&gt;
                              &lt;/form&gt;
  </code></pre>
  <p><strong>Edit</strong></p>
  <p>After solving previous problems, I'm stuck on another error:</p>
  <pre><code>Call to a member function delete() on array 
  </code></pre>
  <p>Here is how my &quot;CityController&quot;s function looks like after updates</p>
  <pre><code>public function delete(Request $request)
      {
          $cityId = $request-&gt;get('cityId', false);
      // TODO: Check for validation
      $todelte = DB::select('select '.$cityId.' from cities');
      $todelte -&gt; delete();
      return redirect('frontend/city/index');
      }
  </code></pre>
  <p>Correct query to delete stuff:
  DB::table('cities')-&gt;where('id', $cityId)-&gt; delete();</p>