Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

haxordeveloper's avatar

InvalidArgumentException View [admin.products.view_products] not found.

hi, m trying to show database records in admin panel and its showing me error: InvalidArgumentException View [admin.products.view_products] not found. any solution to resolve it??

my function is:

  public function viewProducts(){
    $products = Product::get();
    $products = json_decode(json_encode($products));
    //echo "<pre>"; print_r($products); die;
    return view('admin.products.view_products')->with(compact('products'));
}

Route is:

  Route::get('/admin/view-products','ProductsController@viewProducts');

this is form:

        <thead>
            <tr>
              <th>Product ID</th>
              <th>Category ID</th>
              <th>Product Name</th>
              <th>Product Code</th>
              <th>Product Color</th>
              <th>Price</th>
              <th>Actions</th>
            </tr>
          </thead>
          <tbody>
            @foreach($products as $product)
            <tr class="gradeX">
              <td>{{ $product->id }}</td>
              <td>{{ $product->category_id }}</td>
              <td>{{ $product->product_name }}</td>
              <td>{{ $product->product_code }}</td>
              <td>{{ $product->product_color }}</td>
              <td>{{ $product->price }}</td>
              <td class="center"><a href="{{ url('/admin/edit-product/'.$product->id) }}" class="btn 
    btn-primary btn-mini">Edit</a> <a id="delCat" href="{{ url('/admin/delete- 
     product/'.$product->id) }}" class="btn btn-danger btn-mini">Delete</a></td>
            </tr>
            @endforeach
0 likes
8 replies
vajid's avatar

look if view_product file is present or not

resources/views/admin/products/view_products.blade.php

munazzil's avatar

Compact function use as like this and i think you don't have a admin.products.view_products change as like below.

 public function viewProducts(){
        $products = Product::all();
        $products = json_decode(json_encode($products));
        
        return view('admin.view_products',compact('products'));
    }
munazzil's avatar

Can you sow your result using below code in cmd.

    php artisan route:list
vajid's avatar
vajid
Best Answer
Level 3

show us your resource folder content like

resources
    js
    scss
    views
        admin
                view_product.blade.php
                ...
                ...
haxordeveloper's avatar

@munazzil E:\xampp\htdocs\laravel\ecom2> php artisan route:list +--------+---------------+----------------------------+------------------+------ ------------------------------------------------------------------+------------- -+ | Domain | Method | URI | Name | Actio n | Middleware | +--------+---------------+----------------------------+------------------+------ ------------------------------------------------------------------+------------- -+ | | GET|HEAD | / | | Closu re | web | | | GET|POST|HEAD | admin | | App\H ttp\Controllers\AdminController@login | web | | | GET|POST|HEAD | admin/add-category | | App\H ttp\Controllers\CategoryController@addCategory | web,auth | | | GET|POST|HEAD | admin/add-product | | App\H ttp\Controllers\ProductsController@addProduct | web,auth | | | GET|HEAD | admin/check-pwd | | App\H ttp\Controllers\AdminController@chkPassword | web,auth | | | GET|HEAD | admin/dashboard | | App\H ttp\Controllers\AdminController@dashboard | web,auth | | | GET|POST|HEAD | admin/delete-category/{id} | | App\H ttp\Controllers\CategoryController@deleteCategory | web,auth | | | GET|POST|HEAD | admin/edit-category/{id} | | App\H ttp\Controllers\CategoryController@editCategory | web,auth | | | GET|HEAD | admin/settings | | App\H ttp\Controllers\AdminController@settings | web,auth | | | GET|POST|HEAD | admin/update-pwd | | App\H ttp\Controllers\AdminController@updatePassword | web,auth | | | GET|HEAD | admin/view-categories | | App\H ttp\Controllers\CategoryController@viewCategories | web,auth | | | GET|HEAD | admin/view-products | | App\H ttp\Controllers\ProductsController@viewProducts | web,auth | | | GET|HEAD | api/user | | Closu re | api,auth:api | | | GET|HEAD | home | home | App\H ttp\Controllers\HomeController@index | web,auth | | | GET|HEAD | login | login | App\H ttp\Controllers\Auth\LoginController@showLoginForm | web,guest | | | POST | login | | App\H ttp\Controllers\Auth\LoginController@login | web,guest | | | POST | logout | logout | App\H ttp\Controllers\Auth\LoginController@logout | web | | | GET|HEAD | logout | | App\H ttp\Controllers\AdminController@logout | web | | | POST | password/email | password.email | App\H ttp\Controllers\Auth\ForgotPasswordController@sendResetLinkEmail | web,guest | | | POST | password/reset | password.update | App\H ttp\Controllers\Auth\ResetPasswordController@reset | web,guest | | | GET|HEAD | password/reset | password.request | App\H ttp\Controllers\Auth\ForgotPasswordController@showLinkRequestForm | web,guest | | | GET|HEAD | password/reset/{token} | password.reset | App\H ttp\Controllers\Auth\ResetPasswordController@showResetForm | web,guest | | | POST | register | | App\H ttp\Controllers\Auth\RegisterController@register | web,guest | | | GET|HEAD | register | register | App\H ttp\Controllers\Auth\RegisterController@showRegistrationForm | web,guest | +--------+---------------+----------------------------+------------------+------ ------------------------------------------------------------------+------------- -+

haxordeveloper's avatar

@VAJID - sory there was just a spell mistake,,,after seeing this comment i focus and saw that there was a spell mistake

Please or to participate in this conversation.