skip to Main Content

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

enter image description here

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


  1. Add this on top of your web.php

    Use AppHttpControllerssettingsControllercontactController.php;
    
    Login or Signup to reply.
  2. 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:

    namespace AppHttpControllers;
    

    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:

    use AppModelsSettings;
    

    After that If you want to retrieve data form that modal you can simply do this:

    $data = Settings::find($id);
    

    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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search