Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

480
Views
Class not found laravel 8 only on production

Hello I'm new to Laravel and Eloquent, all I found about this problems it that it can by Case sensitivity problems but I can't find any case problems.

:Error message

Class "App\Models\TvEpisode" not found

I'm trying to get UserTvEpisode list to view it works fine in localhost (using Windows), but not on production server in throws an error that the class TvEpisode is not found.

User has many UserTvEpisode 's . TvEpisode has many UserTvEpisode 's .

Filenames: TvEpisode.php , UserTvEpisode.php, TvEpisodeController.php

Controller that tries to get list:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\UserTvEpisode;
use App\Models\TvEpisode;
use Auth;

class TvEpisodeController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $user = Auth::user();    
       
        $allTvEpisodes = UserTvEpisode::with('TvEpisode')->where("user_id", "=",  $user->id)->get();
        
        return view('tvepisode.index',[
            'allTvEpisodes' => $allTvEpisodes
        ]);
    }
}

UserTvEpisode model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\TvEpisode;

class UserTvEpisode extends Model
{
    use HasFactory;
    protected $table = 'user_tv_episodes';

    protected $primaryKey = 'id';

    public $timestamps = true;

    protected $dataFormate ='h:m:s';

    public function TvEpisode(){
        return $this->belongsTo(TvEpisode::class)->withDefault();;
    }
    public function user(){
        return $this->belongsTo(User::class);
    }

}

TvEpisode model

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use App\Models\UserTvEpisode;

class TvEpisode extends Model
{
    use HasFactory;
    protected $table = 'tv_episodes';

    protected $primaryKey = 'id';

    public $timestamps = false;

    protected $dataFormate ='h:m:s';

    public function userTvEpisodes(){
        return $this->hasMany(UserTvEpisode::class);
    }
}

What am I missing here?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

If you are sure that there are no case sensitivity problems, you could try a couple of things:

  1. Check if the namespaces of your classes are correct. Do the classes exists in the right directory, models in App\Models and the controller in App\Http\Controllers? If not, move the class or change the namespace.
  2. Are you sure the file exists on the server? Is the project on the server up-to-date with your local project?
  3. Run composer dump-autoload on the server to regenerate list of classes used in the project.

I am pretty sure one of the solution above will solve your problem.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!