采摘拉拉维尔需要很多元素?

时间:2017-12-31 18:26:38

标签: php laravel

public function getPackage($type)
{
    $sale = Tour::where('id_package',$type)->get();
    $pack = Package::where('id',$sale->pluck('id_package'))->get();
    $loca = Location::where('id','=',$sale->pluck('id_location'))->get();
    return view('page.package',compact('pack','loca','sale'));
}

当我使用dd($ sale-> pluck('id_location')时,我可以获得两个元素,但是当我将$ loca分配给一个时,当我使用whereIn('id',$ sale-> pluck('id_location')我可以获得两个元素但与id tour @@

不匹配

谢谢

1 个答案:

答案 0 :(得分:0)

您无法将#!/usr/bin/env python3 # -*- coding: utf-8 -*- import sys import os from PySide.QtCore import * from PySide.QtGui import * class UI(QDialog): def __init__(self, *args, **kwargs): super(UI, self).__init__(**kwargs) outerBox = QGroupBox(self) outerBox.setGeometry(50, 50, 200, 150) outerBox.setObjectName("outerBox") brokenCss = "QPushButton:closed {" brokenCss += " background-color: #ce9a9a;" # red-ish brokenCss += " border: 1px outset #000000;" brokenCss += " border-radius: 6px;" brokenCss += "}" brokenCss += "QPushButton:open {" brokenCss += " background-color: #12f785;" # green-ish brokenCss += " border: 1px inset #000000;" brokenCss += " border-radius: 6px;" brokenCss += "}" broken = [] for i in range(2): broken.append(QPushButton(outerBox)) broken[i].setObjectName("broken{0}".format(i)) broken[i].setGeometry(15, (35 * (i + 1)), 100, 20) broken[i].setText("Broken CSS {0}".format(i)) broken[i].setCheckable(True) broken[i].setChecked(False) broken[i].setStyleSheet(brokenCss) if __name__ == '__main__': app = QApplication(sys.argv) ui = UI() ui.showFullScreen() sys.exit(app.exec_()) 与集合一起使用,请使用以下语法使用where()

whereIn()

此外,如果您要加载$sale = Tour::where('id_package', $type)->get(); $pack = Package::whereIn('id', $sale->pluck('id_package'))->get(); $loca = Location::whereIn('id', $sale->pluck('id_location'))->get(); 相关的套餐和位置,则应定义关系并use eager loading

Tours