Groups in config
Right now we define groups in config this way:
'groups' => [
'acquaintances' => 0,
'close_friends' => 1,
'family' => 2
]
It means that developer has to associate a name to each group somewhere else based on slug. for ex:
[
...
'close_friends' => 'Close Friends',
...
]
What do you think if we let developer specify public names right in the config. I see 2 ways of doing this.
- Use only slugs like 'best_friend' and not indexes to store a group in DB. It will take more space in DB, but makes it more readable. Then config should look like
'groups' => [
'acquaintances' => 'Acquaintances',
'close_friends' => 'Close Friends',
'family' => 'My Family'
]
- Use array for each group.
'groups' => [
0 => [
'slug'=> 'acquaintances',
'name'=> 'Acquaintances'
],
1 => [
'slug'=> 'close_friends',
'name'=> 'Close Friends'
],
2 => [
'slug'=> 'family',
'name'=> 'My Super Family'
]
]
What do you think would be a better way?
Hm, I think that first way looks better since it more dynamic. Meaning that if a dev decides to remove some groups the config will remain clean instead of having something like this:
'groups' => [
0 => [
'slug'=> 'acquaintances',
'name'=> 'Acquaintances'
],
4 => [
'slug'=> 'close_friends',
'name'=> 'Close Friends'
],
5 => [
'slug'=> 'family',
'name'=> 'My Super Family'
]
]
However, what do you think about storing the groups in the db?
@hootlex I was also thinking about that but it's another migration and table for usually 1-3 rows (close friends, family, acquaintances). We can do that though.
With introducing a table we can allow each user have his own set of groups... but it's another story. What do you think?
Hmm. I haven't thought about this yet. I was just asking 😄
We can discuss the db solution when we are migrating to V2.
@nikolaynesov (I've sent you an invitation for the Gitter room)
I'd be willing to pitch in, I used the package in one of my projects, would like to help make it better :)
@JadJabbour I am happy to hear that. Do you have something specific in mind?
@hootlex moving groups into database sounds really cool, as in most cases groups are not predefined but managed by the users themselves, and moreover, each has own set of groups for his/her "friends".
i have some problem in join a friend in a group $user = Auth::user(); $group_name=user_group::find($group_id); $friend=Friendship::find($friend_id); $user->groupFriend($friend, $group_name);
I have not any idea for the parameter in groupFriend($friend, $group_name);
its give error Argument 1 passed to Illuminate\Database\Grammar::columnize() must be of the type array, string given, called in /var/www/html/krug_me/vendor/laravel/framework/src/Illuminate/Database/Query/Grammars/Grammar.php on line 131 and defined