I already work in a web application in Laravel that needs a rating system between users. So, I read the Laravel documentation and some posts here and there, but I keep wondering what is the best way to accomplish what I want to do. I can not solve the following two options.
My current tables:
users (id) | tariffs (id, sender, comment, bid) | user_rate (id, user_id, rate_id)
My current user model:
public function rates_sent(){ return $this->hasMany(Rate::class,"sender"); } public function rates(){ return $this->belongsToMany(Rate::class); }
My current bid model:
public function sender(){ return $this->belongsTo(User::class,"sender"); } public function receiver(){ return $this->belongsToMany(User::class); }
The second option:
users (id) | tariffs (id, sender, recipient, comment, bid)
User Model:
public function rates_sent(){ return $this->hasMany(Rate::class,"sender"); } public function rates_received(){ return $this->hasMany(Rate::class,"receiver"); }
Speed ββModel:
public function sender(){ return $this->belongsTo(User::class,"sender"); } public function receiver(){ return $this->belongsTo(UseR::class,"receiver"); }
So are both good solutions? Is one option more acceptable than the other? Is there also a better option for this?
I apologize for my bad prints. thanks in advance