1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- class Guessing extends Model
- {
- protected $table='guessing';
- public function get_user(){
- return $this->belongsTo(User::class,'user_id');
- }
- public function get_guessing(){
- return $this->hasMany(Guessing::class,'user_id','user_id');
- }
- public function get_challenge(){
- return $this->belongsTo(Challenge::class,'challenge_id');
- }
- public function get_challenge_challenge_user(){
- return $this->belongsToMany(User::class,'challenge','id','challenge_id','challenge_id','id')->withPivot('challenge_total','accept_total','challenge_day','challenge_success_id');
- }
- public function get_challenge_accept_user(){
- return $this->belongsToMany(User::class,'challenge','id','accept_id','challenge_id','id');
- }
- }
|