web.php
<?php
use AppHttpControllerssettingsControllerseoController;
use AppHttpControllerssettingsControllercontactController;
use IlluminateSupportFacadesRoute;
use AppHttpControllersgeneralControllergeneralRoutes;
use AppHttpControllerssettingsControllerusersController;
Route::controller(generalRoutes::class)->group(function () {
Route::get('/', 'index')->name('index');
Route::get('/getNews', 'getNews');
});
Route::prefix('settings')->group(function () {
Route::controller(contactController::class)->group(function () {
Route::get('/contact', 'index')->name('contactIndex');
Route::post('/contact/update/general', 'generalContactUpdate')->name('generalSContactUpdate');
Route::post('/contact/update/html', 'staticHtmlUpdate')->name('staticHtmlUpdate');
});
});
contactController
<?php
namespace AppHttpControllerssettingsController;
use AppHttpControllersController;
use IlluminateHttpRequest;
class contactController extends Controller
{
public function index(){
$data = Settings::find(1);
return view('settings.contact',compact('data'));
}
I wanted create contactController, I had this problem before
Class "AppHttpControllerssettingsControllercontactController" not found
I solve it but now it gives settingsController error
Class "AppHttpControllerssettingsControllerSettings" not found
Please help me))
I want create contactController but it gives settingsController problem
2
Answers
Add this on top of your web.php
Hey Just for clearing your doubts giving you some hint for this basic question.
If you want to use controller you can use it with the help of namespaces like below:
And if you want to fix this error Class
"AppHttpControllerssettingsControllerSettings" not found
First, you need to specify the modal from where you want the data like this:
After that If you want to retrieve data form that modal you can simply do this:
Hope it will help you for basic understanding the usage of controllers and modals in laravel. If you are still struggling with the issue below doc link will surely help you. Keep Learning.
https://laravel.com/docs/9.x/controllers#basic-controllers