Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Target class [App\Http\Controller\ContactController] does not exist. Laravel 9

i am beginner of laravel. i ran into the problem .Target class [App\Http\Controller\ContactController] does not exist.
i set the all the routes files currectly.i don’t why this errors is displaying.

ContactController

 public function index()
    {
        $contacts = Contact::all();
        return view('contact.index')->with('contacts',$contacts);
    }

View Page

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

@extends('layout')

@section('content')

<div class="card">
        <div class="card-header">About</div>
        <div class="card-body">  

            @foreach($contacts as $contact)
            <p>{{ $contact->name }}</p>
            <p>{{ $contact->address }}</p>
            <p>{{ $contact->mobile }}</p> 
            @endforeach
        </div>
    </div>



@stop

i attached the screen shot image below.
enter image description here

Routes

use App\Http\Controller\ContactController;

    Route::resource('/contact',ContactController::class);

>Solution :

The controllers live in App\Http\Controllers, so edit

use App\Http\Controller\ContactController;

to

use App\Http\Controllers\ContactController;

make sure the file namespace is correct too

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading