Guessing.php 853 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Guessing extends Model
  5. {
  6. protected $table='guessing';
  7. public function get_user(){
  8. return $this->belongsTo(User::class,'user_id');
  9. }
  10. public function get_guessing(){
  11. return $this->hasMany(Guessing::class,'user_id','user_id');
  12. }
  13. public function get_challenge(){
  14. return $this->belongsTo(Challenge::class,'challenge_id');
  15. }
  16. public function get_challenge_challenge_user(){
  17. return $this->belongsToMany(User::class,'challenge','id','challenge_id','challenge_id','id')->withPivot('challenge_total','accept_total','challenge_day','challenge_success_id');
  18. }
  19. public function get_challenge_accept_user(){
  20. return $this->belongsToMany(User::class,'challenge','id','accept_id','challenge_id','id');
  21. }
  22. }