Error Class 'app Course' not found

Asked

Viewed 1,754 times

0

I’m with this mistake when listing all courses in a CRUD in Laravel

"Class 'app Course' not found"

Since there is this class, I will show in codes and images...

inserir a descrição da imagem aqui

Controller code:

<?php

namespace app\Http\Controllers\Admin;

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

class CursosController 

    extends Controller
    {
        public function index(){
            $registros = Curso::all();
            return view('admin.cursos.index', compact('registros'));
        }
    }

Class code

<?php

namespace app;

use Illuminate\Database\Eloquent\Model;


class Curso extends Model
{
    //
}

Thanks if you can help me, because it’s a college job!

  • Only error with the course model? Open the user model and compare with the course model.

  • 3

    use App Course ... App starts with uppercase letter. And in the model the namespace is App .. with uppercase letter tmb.. Look at your Komposer.json ... psr-4 .. " App ": "app/" ..

  • 1

    @Darleifernandozillmer About the edition, Laravel is a proper name that refers to the PHP framework. It should not be code formatting.

2 answers

2

You need to change two things.

No Model use:

namespace App;

And in Controller:

use App\Curso;

0

Instead of

use app\Curso;

try

use App\Curso;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.