The relationship is a game and its location. It displays a list of the games at that location. It then eager loads the location name on the table along with game info.
My other tables that don't include eloquent relationships work just fine.
Again this works just fine in my wamp but not in my shared hosting Cpanel environment.
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Game extends Model
{
//
public $timestamps = false;
protected $guarded = ['id'];
public function location(){
return $this->belongsTo('App\Models\location');
}
public function scores(){
return $this->belongsToMany('App\Models\User')->withPivot(['id','score','placed','check_in']);
}
}
Model for location
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Location extends Model
{
//
public $timestamps = false;
protected $guarded = ['id'];
public function games(){
return $this->hasMany('App\Models\Game');
}
}
I installed Laravel/composer on Cpanel through Softaculous Installer. Which gave me a blank laravel application then I copied over/overrode the files that needed to be added/updated.
public function location(){
return $this->belongsTo('App\Models\location');
}
To this:
public function location(){
return $this->belongsTo(Location::class);
}
Both files are in the App\Models directory, so not needed to declare the full namespace. Also, you declared location instead of Location, that's why you're getting that App\Models\location not found error..
You can also just change the location to Location:
public function location(){
return $this->belongsTo('App\Models\Location');
}
.....OMG, it was because I was using 'l' in location and now 'L'.... omg... Thank you guys so much... I spent my whole day so very lost..... Thank you soo much.