Nov 30, 2016
0
Level 21
Pivot Table with values (and values history)
So, basically I have 2 models\ 3 tables:
users
id - integer
skills
id - integer
skill_user (pivot table)
skill_id - integer
user_id - integer
level - float
created_at
updated_at
and relationships:
- in the User Model:
/**
* Return the skills associated to this user
* @return [type] [description]
*/
public function skills() {
return $this->belongsToMany('App\Skill')
->withPivot('level')
->withTimestamps();
}
- in the Skills Model:
/**
* Return the users associated to this skill
* @return [type] [description]
*/
public function users() {
return $this->belongsToMany('App\User')
->withPivot('level')
->withTimestamps();
}
What I want is to track the skill level along the time. How would be the best way to achieve this? Can I have multiple attached values in the pivot table with different levels and different timestamps? Or should I create new model\table which should be updated every time the level will be updated ?
Please or to participate in this conversation.