Adds incident visibility. Closes #602

This commit is contained in:
James Brooks
2015-05-20 08:41:02 +01:00
committed by James Brooks
parent 9257135641
commit df2ae7726d
9 changed files with 89 additions and 6 deletions

View File

@@ -24,13 +24,16 @@ class IncidentController extends AbstractApiController
* Get all incidents.
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \CachetHQ\Cachet\Models\Incident $incident
* @param \Illuminate\Contracts\Auth\Guard $auth
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getIncidents(Request $request)
public function getIncidents(Request $request, Guard $auth)
{
$incidents = Incident::paginate(Binput::get('per_page', 20));
$incidentVisiblity = $auth->check() ? 0 : 1;
$incidents = Incident::where('visible', '>=', $incidentVisiblity)
->paginate(Binput::get('per_page', 20));
return $this->paginator($incidents, $request);
}

View File

@@ -19,6 +19,7 @@ use CachetHQ\Cachet\Models\Metric;
use Exception;
use GrahamCampbell\Binput\Facades\Binput;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Jenssegers\Date\Date;
@@ -65,7 +66,9 @@ class HomeController extends AbstractController
$incidentDays = range(0, $daysToShow - 1);
$dateTimeZone = Setting::get('app_timezone');
$allIncidents = Incident::notScheduled()->whereBetween('created_at', [
$incidentVisiblity = Auth::check() ? 0 : 1;
$allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [
$startDate->copy()->subDays($daysToShow)->format('Y-m-d').' 00:00:00',
$startDate->format('Y-m-d').' 23:59:59',
])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use ($dateTimeZone) {