我有一个SQL查询,希望将其转换为Eloquent集合,以便返回更多的迁移数据。我可以阅读Eloquent语法,但无法弄清楚如何正确编写。
<div class="modal" id="addEditCapModal" role="dialog" data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg">
<asp:UpdatePanel ID="UpAddEditCaptureAmmount" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSave" />
<asp:AsyncPostBackTrigger ControlID="btnClose" />
</Triggers>
<ContentTemplate>
<div class="modal-content">
<div class="modal-header bg-info">
<asp:LinkButton runat="server" CssClass="btn btn-xs btn-danger pull-right" data-dismiss="modal">
<span class="glyphicon glyphicon-remove"></span>
</asp:LinkButton>
<h4 class="modal-title">
<asp:Label ID="lbTitle" runat="server"></asp:Label>
</h4>
</div>
<div class="modal-body">
<div class="panel panel-primary">
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="input-group input-item">
<bst:ControlInput runat="server" Prompt="Водомер:" ID="cControlID" OnControlLoaded="cControlID_ControlLoaded" />
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer bg-info">
<asp:Label runat="server" ID="lbMessage"></asp:Label>
<asp:LinkButton ID="btnSave" runat="server" CssClass="btn btn-sm btn-success" OnClick="btnSave_Click">Запази</asp:LinkButton>
<asp:LinkButton ID="btnClose" runat="server" CssClass="btn btn-sm btn-danger" data-dismiss="modal">Затвори</asp:LinkButton>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
以上是我的SQL查询。我不确定还需要其他哪些数据/信息。但是可以根据需要提供。
已经建立的事件集合如下
$pastIssues = DB::select(
"SELECT incident_id, status, message, user_id, created_at, updated_at, 'i' as source,
(
SELECT name FROM incidents
WHERE id = ?
)
AS title FROM incident_updates
WHERE incident_id
IN (
SELECT id FROM incidents
WHERE id = ?
)
UNION SELECT schedule_id, status, message, user_id, created_at, updated_at, 'm' as source,
(
SELECT name FROM schedules
WHERE id = schedule_id
)
AS title FROM schedule_updates
WHERE schedule_id
IN (
SELECT id from schedules
WHERE component_id = ?
)
ORDER BY created_at DESC;", [$componentId, $componentId, $componentId]);
已经建立的维护集合如下
allIncidents = Incident::where('visible', '>=', (int) !Auth::check())->where('component_id', '=', $component->id)->where('status', '=', 4)->whereBetween('occurred_at', [
$startDate->copy()->subDays($appIncidentDays)->format('Y-m-d').' 00:00:00',
$startDate->format('Y-m-d').' 23:59:59',
])->orderBy('occurred_at', 'desc')->get()->groupBy(function (Incident $incident) {
return app(DateFactory::class)->make($incident->occurred_at)->toDateString();
});
我最初的想法是设法将两者合并在一起?看到它们没有完全相同的列结构,这是行不通的。