Incidents belong to a component. Tidy and docbloc code too.

This commit is contained in:
James Brooks
2014-11-25 09:08:04 +00:00
parent b931c59ae6
commit 7dd54010a2
2 changed files with 36 additions and 20 deletions

View File

@@ -14,22 +14,26 @@ class IncidentTableSeeder extends Seeder {
$defaultIncidents = [ $defaultIncidents = [
[ [
"name" => "Test Incident", "name" => "Test Incident",
"message" => "Something went wrong, oh noes." "message" => "Something went wrong, oh noes.",
"component" => 1,
], ],
[ [
"name" => "Update", "name" => "Update",
"message" => "We've found the problem, so we're looking at it.", "message" => "We've found the problem, so we're looking at it.",
"status" => 2 "status" => 2,
"component" => 1,
], ],
[ [
"name" => "Monitoring the fix", "name" => "Monitoring the fix",
"message" => "We're checking that our fix will first work.", "message" => "We're checking that our fix will first work.",
"status" => 3 "status" => 3,
"component" => 1,
], ],
[ [
"name" => "Awesome", "name" => "Awesome",
"message" => "We totally nailed the fix.", "message" => "We totally nailed the fix.",
"status" => 4 "status" => 4,
"component" => 2,
] ]
]; ];

View File

@@ -1,6 +1,18 @@
<?php <?php
class Incident extends Eloquent { class Incident extends Eloquent {
/**
* An incident belongs to a component.
* @return Illuminate\Database\Eloquent\Relations
*/
public function parent() {
return $this->belongsTo('Component', 'component', 'id');
}
/**
* Returns a human readable version of the status.
* @return string
*/
public function getHumanStatusAttribute() { public function getHumanStatusAttribute() {
switch ($this->status) { switch ($this->status) {
case 1: return 'Investigating'; case 1: return 'Investigating';
@@ -10,29 +22,29 @@
} }
} }
/**
* Looks up the class name for the status.
* @return string
*/
public function getColorAttribute() { public function getColorAttribute() {
switch ($this->status) { switch ($this->status) {
case 1: case 1: return 'warning';
return 'warning'; case 2: return 'alert';
case 2: case 3: return 'info';
return 'alert'; case 4: return 'success';
case 3:
return 'info';
case 4:
return 'success';
} }
} }
/**
* Finds the icon to use for each status.
* @return string
*/
public function getIconAttribute() { public function getIconAttribute() {
switch ($this->status) { switch ($this->status) {
case 1: case 1: return 'glyphicon-flag';
return 'glyphicon-flag'; case 2: return 'glyphicon-warning-sign';
case 2: case 3: return 'glyphicon-eye-open';
return 'glyphicon-warning-sign'; case 4: return 'glyphicon-ok';
case 3:
return 'glyphicon-eye-open';
case 4:
return 'glyphicon-ok';
} }
} }
} }