title: route resource update and delete not working using multiple roles except store laravel 8
body: <p>I want to <code>delete</code> my admin product using a route resource. But when I submit, it goes to page <code>404</code> same as <code>update</code> method.. But my URL <code>id</code> is showing...</p>
  <p>This is the URL on <code>destroy</code> method <code>http://127.0.0.1:8000/admin/1</code>  but the store is working fine. It's directing to my URL and <code>stored</code> in database.</p>
  <p>This is my <code>store</code> method on <code>Admin/ProductController</code> resource:</p>
  <pre><code>public function store(Request $request)
  {
      $request['user_id'] = auth()-&gt;user()-&gt;id;
      Product::create($request-&gt;all());
  
      return redirect()-&gt;back();
  }
  </code></pre>
  <p>This is my <code>destroy</code> method on <code>Admin/ProductController</code> resource:</p>
  <pre><code> public function destroy($id)
   {
       Product::where('id', $id-&gt;id)-&gt;delete();
  
       return redirect()-&gt;back();
   }
  </code></pre>
  <p>Here is my form action <code>store</code> method. This form is working fine:</p>
  <pre><code>&lt;form method=&quot;post&quot; action=&quot;{{route('admin.store')}}&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;category&quot; class=&quot;form-control&quot;&gt;
      &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Save changes&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Here is my form action <code>delete</code>. The problem is when I submit, it goes to <code>404</code> page:</p>
  <pre><code>&lt;form method=&quot;post&quot; action=&quot;{{ route('admin.destroy', $product-&gt;id) }}&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;category&quot; class=&quot;form-control&quot;&gt;
      &lt;button type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;Save changes&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Here is my route <code>user</code> and <code>admin</code>:</p>
  <pre><code>Route::get('/', function () {
      return view('welcome');
  });
  
  Auth::routes();
  
  Route::group(['as' =&gt; 'user.', 'prefix' =&gt; 'users', 'namespace' =&gt; 'App\Http\Controllers\Users'], function() {
      Route::get('/', [App\Http\Controllers\Users\UsersController::class, 'index']);
      Route::resources(['/' =&gt; ProductController::class], ['except' =&gt; ['index']]);
  });
  
  Route::group(['middleware' =&gt; 'admin', 'as' =&gt; 'admin.', 'prefix' =&gt; 'admin', 'namespace' =&gt; 'App\Http\Controllers\Admin'], function() {
      Route::get('/', [App\Http\Controllers\Admin\AdminController::class, 'index']);
      Route::resources(['/' =&gt; ProductController::class], ['except' =&gt; ['index']]);
  });
  </code></pre>
  <p>Here is my route list:</p>
  <pre><code>+--------+-----------+------------------------+------------------+------------------------------------------------------------------------+------------+
  | Domain | Method    | URI                    | Name             | Action                                                                 | Middleware |
  +--------+-----------+------------------------+------------------+------------------------------------------------------------------------+------------+
  |        | GET|HEAD  | /                      |                  | Closure                                                                | web        |
  |        | POST      | admin                  | admin.store      | App\Http\Controllers\Admin\ProductController@store                     | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | GET|HEAD  | admin                  | admin.index      | App\Http\Controllers\Admin\ProductController@index                     | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | GET|HEAD  | admin/create           | admin.create     | App\Http\Controllers\Admin\ProductController@create                    | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | DELETE    | admin/{}               | admin.destroy    | App\Http\Controllers\Admin\ProductController@destroy                   | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | PUT|PATCH | admin/{}               | admin.update     | App\Http\Controllers\Admin\ProductController@update                    | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | GET|HEAD  | admin/{}               | admin.show       | App\Http\Controllers\Admin\ProductController@show                      | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | GET|HEAD  | admin/{}/edit          | admin.edit       | App\Http\Controllers\Admin\ProductController@edit                      | web        |
  |        |           |                        |                  |                                                                        | admin      |
  |        | GET|HEAD  | api/user               |                  | Closure                                                                | api        |
  |        |           |                        |                  |                                                                        | auth:api   |
  |        | POST      | login                  |                  | App\Http\Controllers\Auth\LoginController@login                        | web        |
  |        |           |                        |                  |                                                                        | guest      |
  |        | GET|HEAD  | login                  | login            | App\Http\Controllers\Auth\LoginController@showLoginForm                | web        |
  |        |           |                        |                  |                                                                        | guest      |
  |        | POST      | logout                 | logout           | App\Http\Controllers\Auth\LoginController@logout                       | web        |
  |        | GET|HEAD  | password/confirm       | password.confirm | App\Http\Controllers\Auth\ConfirmPasswordController@showConfirmForm    | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | POST      | password/confirm       |                  | App\Http\Controllers\Auth\ConfirmPasswordController@confirm            | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | POST      | password/email         | password.email   | App\Http\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail  | web        |
  |        | GET|HEAD  | password/reset         | password.request | App\Http\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web        |
  |        | POST      | password/reset         | password.update  | App\Http\Controllers\Auth\ResetPasswordController@reset                | web        |
  |        | GET|HEAD  | password/reset/{token} | password.reset   | App\Http\Controllers\Auth\ResetPasswordController@showResetForm        | web        |
  |        | GET|HEAD  | register               | register         | App\Http\Controllers\Auth\RegisterController@showRegistrationForm      | web        |
  |        |           |                        |                  |                                                                        | guest      |
  |        | POST      | register               |                  | App\Http\Controllers\Auth\RegisterController@register                  | web        |
  |        |           |                        |                  |                                                                        | guest      |
  |        | GET|HEAD  | users                  | user.            | App\Http\Controllers\Users\UsersController@index                       | web        |
  |        | POST      | users                  | user.store       | App\Http\Controllers\Users\ProductController@store                     | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | GET|HEAD  | users/create           | user.create      | App\Http\Controllers\Users\ProductController@create                    | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | DELETE    | users/{}               | user.destroy     | App\Http\Controllers\Users\ProductController@destroy                   | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | GET|HEAD  | users/{}               | user.show        | App\Http\Controllers\Users\ProductController@show                      | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | PUT|PATCH | users/{}               | user.update      | App\Http\Controllers\Users\ProductController@update                    | web        |
  |        |           |                        |                  |                                                                        | auth       |
  |        | GET|HEAD  | users/{}/edit          | user.edit        | App\Http\Controllers\Users\ProductController@edit                      | web        |
  |        |           |                        |                  |                                                                        | auth       |
  +--------+-----------+------------------------+------------------+---------------------------------------
  </code></pre>
  <p>Here is my <code>App\Http\Auth\LoginController</code>:</p>
  <pre class="lang-php prettyprint-override"><code>namespace App\Http\Controllers\Auth;
  
  use App\Http\Controllers\Controller;
  use App\Providers\RouteServiceProvider;
  use Illuminate\Foundation\Auth\AuthenticatesUsers;
  use Illuminate\Http\Request;
  
  class LoginController extends Controller
  {
      use AuthenticatesUsers;
  
      protected $redirectTo = RouteServiceProvider::HOME;
  
      public function __construct()
      {
          $this-&gt;middleware('guest')-&gt;except('logout');
      }
  
      public function login(Request $request)
      {
          $inputVal = $request-&gt;all();
  
          $this-&gt;validate($request, [
              'email' =&gt; 'required|email',
              'password' =&gt; 'required',
          ]);
  
          if (auth()-&gt;attempt(['email' =&gt; $inputVal['email'], 'password' =&gt; $inputVal['password']])) {
              if (auth()-&gt;user()-&gt;role == 'admin') {
                  return redirect()-&gt;route('admin.');
              } else {
                  return redirect()-&gt;route('user');
              }
          } else {
              return redirect()-&gt;route('login')
                  -&gt;with('error', 'Email &amp; Password are incorrect.');
          }
      }
  }
  </code></pre>
  <p>Here is my <code>admin middleware</code>:</p>
  <pre><code>namespace App\Http\Middleware;
  
  use Closure;
  use Illuminate\Http\Request;
  
  class Admin
  {
      /**
       * Handle an incoming request.
       *
       * @param  \Illuminate\Http\Request  $request
       * @param  \Closure  $next
       * @return mixed
       */
      public function handle(Request $request, Closure $next)
      {
          if (auth()-&gt;user()-&gt;role === 'admin') {
              return $next($request);
          }
  
          return redirect()-&gt;back();
      }
  }
  </code></pre>
  <p>I don't know what is wrong on this, <code>store</code> is working but the <code>update</code> and <code>destroy</code> is not. I guess the error is on <code>route</code> or <code>middleware</code>.</p>