Laravel |使用Eloquent hasManyThrough

时间:2017-11-27 12:36:37

标签: laravel eloquent relationship has-many-through laravel-5.5

我有一个名为ChronoFormatter<CalendarDate> hfShortBiblical = ChronoFormatter.ofGenericCalendarPattern( "MM/dd/yyyy", Locale.forLanguageTag("en-US-u-ca-hebrew") ).with(HebrewMonth.order(), HebrewMonth.Order.BIBILICAL); ChronoFormatter<CalendarDate> hfShortCivil = ChronoFormatter.ofGenericCalendarPattern( "MM/dd/yyyy", Locale.forLanguageTag("en-US-u-ca-hebrew") ).with(HebrewMonth.order(), HebrewMonth.Order.CIVIL); System.out.println(hfShortBiblical.format(gregorian)); // 09/09/5778 System.out.println(hfShortCivil.format(gregorian)); // 03/09/5778 的表SolarTime jerusalem = SolarTime.ofJerusalem(); HebrewCalendar currentHebrewDate = SystemClock.currentMoment().toGeneralTimestamp( HebrewCalendar.axis(), Timezone.ofSystem().getID(), StartOfDay.definedBy(jerusalem.sunset()) ).toDate(); invoiceDetails来自另一个名为item_id的表foreign key,其表itemscategory_idforeign key

我想在使用eloquent之后做到这一点:

categories

但我收到错误:

$result = InvoiceDetail::groupBy('item_id')
                ->selectRaw('sum(qty) as qty, item_id')->with('item', 'category')->get();

这是我在Call to undefined relationship [category] on model [App\InvoiceDetail]. 模型中的关系:

Category

有什么建议吗?

0 个答案:

没有答案