Post model namespace is App so use case sensitive name in your import too.
use App\Post;
instead of use app\Post;
May Sale! All accounts are 40% off this week.
I'm using Laravel 7 and suddenly running into this weird "Class not found" error even though I'm following the default set up and it has been working fine with other controllers. The error message was simply:
Class 'app\Post' not found
My Post.php file is in the app folder, and my PostController.php file is in the app/Http/Controllers folder. The content is as below:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Auth;
use app\Post;
use app\Course;
use app\Comment;
class PostController extends Controller
{
....
public function store(Request $request)
{
$validator = Validator::make($request->all(), Post::$create_rules, Post::$create_messages); //line causing error
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
...
I have tried to dump-autoload but that doesn't seem to help. I'm really confused about what's causing this error.
Post model namespace is App so use case sensitive name in your import too.
use App\Post;
instead of use app\Post;
Please or to participate in this conversation.