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
@extends('layout')
@section('content')
<div >
<div >About</div>
<div >
@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.
Routes
use App\Http\Controller\ContactController;
Route::resource('/contact',ContactController::class);
CodePudding user response:
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