In this line
$the_group = Group::with('users')->Name($query) -> get();
change get() to first() like this:
$the_group = Group::with('users')->Name($query) -> first();
Get returns a collection of Models (even if there are only 0 or 1 results) and the collection doesn't have a relationship, the model has.
So either just retrieve 1 model from the database with first() or loop through your collection to access the single model instances.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community