Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Charrua's avatar

Query failing on prod server but not local

Hello, I having some trouble with some relation query on prod server. Database and files are the same.

On my model Communication I have a polymorphic relationship to the SMSLog model.

/**
* Get delivered SMS's associated with the communication.
* One To Many (Polymorphic)
*/
public function delivered_sms(){

    return $this->morphMany('App\SMSLog', 'model')->where('status', 'delivered');

}

On the communication controller I have:

public function index(){
        
    $communications = \App\Communication::orderBy('created_at', 'desc')
        ->paginate(20);
   
    return view('communication/index', compact('communications'));
}

Then on my blade view I'm using {{ $communication->delivered_sms()->count() }} to count how many delivered messages I have. This works on local but on prod It throws the error:

[2019-07-09 03:40:04] production.ERROR: Class 'App\SMSLog' not found (View: /var/www/vhosts/***/laravel/resources/views/communication/index.blade.php) {"userId":1,"email":"***","exception":"[object] (ErrorException(code: 0): Class 'App\SMSLog' not found (View: /var/www/vhosts/***/laravel/resources/views/communication/index.blade.php) at /var/www/vhosts/***/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php:656, Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Class 'App\SMSLog' not found at /var/www/vhosts/***/laravel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php:656)
0 likes
3 replies
chatty's avatar
chatty
Best Answer
Level 4

check the class name and case-sensitivity of 'App\SMSLog'

munazzil's avatar

I think you have missed to include in your controller below one,

   use App/SMSLog;

and if not clear browser cache,

      php artisan cache:clear
      php artisan view:clear
      php artisan route:clear
Charrua's avatar

oh my... I was using the wrong case, my class is SmsLog and not SMSLog

The weird thing is that on local this runs and on prod no.

Thank you for your help!

Please or to participate in this conversation.