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

manojvarma's avatar

Laravel controller issue

Hi i created a controller by that i want to get the values from database. When i go to that URL i am getting this error "InvalidArgumentException in FileViewFinder.php line 137: View [Stockview.index] not found."

My controller class is like this : `<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;

use Illuminate\Http\Request;

use App\Http\Requests;

use View;

class StockviewController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $devices = DB::table('device')->get();

    return view('stockview.', ['devices' => $devices]);
}

/**
 * Show the form for creating a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create()
{
    //
}

/**
 * Store a newly created resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @return \Illuminate\Http\Response
 */
public function store(Request $request)
{
    //
}

/**
 * Display the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function show($id)
{
    //
}

/**
 * Show the form for editing the specified resource.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function edit($id)
{
    //
}

/**
 * Update the specified resource in storage.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function update(Request $request, $id)
{
    //
}

/**
 * Remove the specified resource from storage.
 *
 * @param  int  $id
 * @return \Illuminate\Http\Response
 */
public function destroy($id)
{
    //
}

}`

And my view is like this : `@extends('layouts.template')

@section('content')

        <div class="clearfix"></div>

        <div class="row">
          
          

          <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
              <div class="x_title">
                <h2> <small></small></h2>
                
                <div class="clearfix"></div>
              </div>
              <div class="x_content">
                <p class="text-muted font-13 m-b-30">
                  
                  </p>
                <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                  <thead>
                    <tr>
                      <th>Serial No</th>
                      <th>OP No</th>
                      <th>Device</th>
                      <th>State</th>
                      <th>Test Status</th>
                      <th>Shipment Status</th>
                      <th>Last Updated Date</th>
                    </tr>
                  </thead>
                  <tbody>

                    foreach($devices as $device)
                    <tr>
                    <td>{{ $value->slno}}</td>
                    <td>{{ $value->opno}}</td>
                    <td>{{ $value->device}}</td>
                    <td>{{ $value->state}}</td>
                    <td>{{ $value->status}}</td>
                  </tbody>
                </table>

              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /page content -->
    @endsection`

And my routing is : Route::resource("stockview", "StockviewController");

0 likes
8 replies
tomopongrac's avatar

You didnt post the code...

It looks like you didin create view Stockview/index.blade.php

tomopongrac's avatar

You need view index.blade.php

Stockview/index.blade.php

Romain's avatar

the "Stockview" folder name should have a capital S

manojvarma's avatar

I have updated the code can u please check it again. Now i am getting the following error "InvalidArgumentException in FileViewFinder.php line 137: View [stockview] not found."

tomopongrac's avatar

You need to add this

return view('stockview.index', ['devices' => $devices]);

and you need to have stockview/index.blade.php

kamalpanhwar's avatar

@manojvarma you must create a view file in your view with directory name of stockview

resources->view->stockview->index.blade.php

make sure you have in you have index.blade.php file in your created stockview folder which is in resource->view folder.

Please or to participate in this conversation.