Home > Mobile >  Class "App\Http\Controllers\settingsController\Settings" not found
Class "App\Http\Controllers\settingsController\Settings" not found

Time:11-30

web.php

<?php

use App\Http\Controllers\settingsController\seoController;
use App\Http\Controllers\settingsController\contactController;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\generalController\generalRoutes;
use App\Http\Controllers\settingsController\usersController;
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 App\Http\Controllers\settingsController;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

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 "App\Http\Controllers\settingsController\contactController" not found

enter image description here

I solve it but now it gives settingsController error Class "App\Http\Controllers\settingsController\Settings" not found Please help me))

I want create contactController but it gives settingsController problem

CodePudding user response:

Add this on top of your web.php

Use App\Http\Controllers\settingsController\contactController.php;

CodePudding user response:

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 App\Http\Controllers;

And if you want to fix this error Class "App\Http\Controllers\settingsController\Settings" not found

First, you need to specify the modal from where you want the data like this:

use App\Models\Settings;

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

  • Related