HasManyThrough与extrafield

时间:2016-11-24 16:47:31

标签: laravel eloquent has-many-through

我有一个关系:

func sendPush(_ receiverID: String, _ who: String, _ didWhat: String, _ message: String?) {

    var subtitle = ""
    var contents = ""
    if message != nil {
        contents = message!
    }

    switch didWhat {
    case "likePost":
        subtitle = "liked your post"
    case "commentPost":
        subtitle = "commented on your post"
    case "likeComment":
        subtitle = "liked your comment"
    case "message":
        subtitle = "sent you a message"
    case "friendsRequest":
        subtitle = "sent you a friend request"
    case "friendAccept":
        subtitle = "accepted your friend request"
    case "follow":
        subtitle = "just followed you"
    default:
        break
    }

    getOneSignalPlayerID(receiverID, completion: { result in

        oneSignal.postNotification(["headings" : ["en": "\(who)"],
                                    "subtitle" : ["en": "\(subtitle)"],
                                    "contents" : ["en": "\(contents)"],
                                    "include_player_ids": [result]],
        onSuccess: { (success) in
            if success != nil {
                print(success!)
            }
        }, onFailure: { (failure) in
            if failure != nil {
                print(failure!)
                crashlyticsLog("getOneSignalPlayerID", failure!.localizedDescription)
            }
        })
    })
}

当我这样做时:

Class Championship extends Model{

 public function fights()
 {
     return $this->hasManyThrough(Fight::class, Tree::class);
 }

}

我得到了我需要的战斗收藏。

但我还需要按区域对它们进行分组,区域属于树($ tree->区域)。

从树????

获得与额外字段的关系是否可行

或者我应该在Fight表中添加区域字段(但听起来像数据重复)

0 个答案:

没有答案