Fetch updates using the eloquent relationship instead of re-querying
This commit is contained in:
@@ -297,9 +297,7 @@ class IncidentController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function showIncidentUpdates(Incident $incident)
|
public function showIncidentUpdates(Incident $incident)
|
||||||
{
|
{
|
||||||
$updates = IncidentUpdate::byIncident($incident)->orderBy('created_at', 'desc')->get();
|
return View::make('dashboard.incidents.updates.index')->withIncident($incident);
|
||||||
|
|
||||||
return View::make('dashboard.incidents.updates.index')->withIncident($incident)->withUpdates($updates);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -74,19 +74,6 @@ class IncidentUpdate extends Model implements HasPresenter
|
|||||||
'user_id',
|
'user_id',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
|
||||||
* Scope all by incident.
|
|
||||||
*
|
|
||||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
|
||||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Builder
|
|
||||||
*/
|
|
||||||
public function scopeByIncident(Builder $query, Incident $incident)
|
|
||||||
{
|
|
||||||
return $query->where('incident_id', '=', $incident->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the incident relation.
|
* Get the incident relation.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
@include('dashboard.partials.errors')
|
@include('dashboard.partials.errors')
|
||||||
|
|
||||||
<div class="striped-list">
|
<div class="striped-list">
|
||||||
@foreach($updates as $update)
|
@foreach($incident->updates as $update)
|
||||||
<div class="row striped-list-item">
|
<div class="row striped-list-item">
|
||||||
<div class="col-xs-6">
|
<div class="col-xs-6">
|
||||||
<strong>{{ Str::words($update->message, 8) }}</strong>
|
<strong>{{ Str::words($update->message, 8) }}</strong>
|
||||||
|
|||||||
Reference in New Issue
Block a user