I've been working on a project in XAMPP on my local system and everything is running great. The code base is stable and the site works well.
I used Forge to leverage Digital Ocean and upload my site. I have the site loaded and find that when I navigate to a specific page I get an error that Laravel can't see my model from a controller. I've used the console on digital ocean and can confirm the php file for the model is in fact present. I'm guessing this might be some difference either in the php version or the Laravel version on forge.
Here's the error I'm getting:
Fatal error: Class 'App\Models\Location' not found
Here's the begining of the controller where the error comes up:
namespace App\Http\Controllers;
use DB;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Models\Profile;
use App\Models\Location;
Maybe check the case of the file (and class name inside) - if you're on Windows (and possibly macos, can't remember) I think it would treat 'location.php' and 'Location.php' as the same thing - but on Linux they are different.
The model file is in fact using an upper case L:
"Location.php"
Here is the contents of the Location.php model:
<?php
namespace App\models;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
public function profiles()
{
return $this->hasMany('Profile');
}
}
A little more info. This seems to be happening on all my controllers. I have another page which references a "Profile.php" controller. And it too generates an error stating "Class 'App\Models\Profile' not found"
Here's the Profile model for it:
<?php
namespace App\models;
use Illuminate\Database\Eloquent\Model;
class Profile extends Model {
public function locations()
{
return $this->hasMany('Location');
}
}