Reputation: 133
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 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.
Routes
use App\Http\Controller\ContactController;
Route::resource('/contact',ContactController::class);
Upvotes: 0
Views: 879
Reputation: 2362
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
Upvotes: 3