Hy !'
do you use the methode name inside with() methode ??
class Amenitie extends \Eloquent
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'amenities';
/**
* @var array
*/
protected $fillable = ['*'];
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function hotels()
{
return $this->belongsToMany('\Grade\Models\Hotel', 'hotels_amenities', 'amenitie_id', 'hotel_id');
}
}
class Hotel extends \Eloquent
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'hotels';
/**
* @var array
*/
protected $fillable = ['*'];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function amenities()
{
return $this->belongsToMany('\Grade\Models\Amenitie', 'hotels_amenities', 'hotel_id', 'amenitie_id');
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function rooms()
{
return $this->hasMany('\Grade\Models\Room', 'hotel_id');
}
}
so ur call shold be like this :
Route::get('test', function () {
return \Grade\Models\Amenitie::with(['hotels','hotels.rooms'])->first();
});
what is clientGroups.Profiles is that the name or the relationship and global scope.
eg: If I have a model called $users and it related to roles and roles has a global scope called adminUsers
I would
User::with('roles')->adminUsers()->get()
I would not
User::with('role.adminUsers')->get()
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community