Fetch updates using the eloquent relationship instead of re-querying

This commit is contained in:
Nico Stapelbroek
2018-01-14 22:17:26 +01:00
parent 72b029e0e9
commit 1da6764b63
3 changed files with 2 additions and 17 deletions
@@ -297,9 +297,7 @@ class IncidentController extends Controller
*/
public function showIncidentUpdates(Incident $incident)
{
$updates = IncidentUpdate::byIncident($incident)->orderBy('created_at', 'desc')->get();
return View::make('dashboard.incidents.updates.index')->withIncident($incident)->withUpdates($updates);
return View::make('dashboard.incidents.updates.index')->withIncident($incident);
}
/**
-13
View File
@@ -74,19 +74,6 @@ class IncidentUpdate extends Model implements HasPresenter
'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.
*