php - Deal with defaults categories for all users but with the possibility of editing/deleting them
one text
I would like to set up a category system on my application.
I would like to offer my users a list of default categories.
Each user should be able to add their own categories or modify existing categories (update or delete) without affecting the categories of other users.
I have a solution but it does not seem ideal to me.
When the user is created, I create entries in the categories
database for each default category. That means if I have 50 default categories, I have to create 50 entries.
public function register() {
// ...
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
Categorie::create(['user_id' => $team->id, 'name' => $name, 'type', $type]);
/..
}
How would you do it?
Source