This commit is contained in:
Graham Campbell
2014-12-30 18:19:22 +00:00
parent df101a27c2
commit 509f582539
36 changed files with 143 additions and 111 deletions
@@ -9,7 +9,6 @@ use Input;
class ComponentController extends Controller class ComponentController extends Controller
{ {
use ControllerTrait; use ControllerTrait;
protected $component; protected $component;
@@ -20,7 +19,7 @@ class ComponentController extends Controller
} }
/** /**
* Get all components * Get all components.
* *
* @return \Illuminate\Database\Eloquent\Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
@@ -30,7 +29,7 @@ class ComponentController extends Controller
} }
/** /**
* Get a single component * Get a single component.
* *
* @param int $id * @param int $id
* *
@@ -42,8 +41,10 @@ class ComponentController extends Controller
} }
/** /**
* Return a component with incidents * Return a component with incidents.
* @param int $id Component ID *
* @param int $id Component ID
*
* @return \Component * @return \Component
*/ */
public function getComponentIncidents($id) public function getComponentIncidents($id)
@@ -52,7 +53,7 @@ class ComponentController extends Controller
} }
/** /**
* Create a new component * Create a new component.
* *
* @return \Component * @return \Component
*/ */
@@ -9,7 +9,6 @@ use Input;
class IncidentController extends Controller class IncidentController extends Controller
{ {
use ControllerTrait; use ControllerTrait;
protected $incident; protected $incident;
@@ -20,7 +19,7 @@ class IncidentController extends Controller
} }
/** /**
* Get all incidents * Get all incidents.
* *
* @return \Illuminate\Database\Eloquent\Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
@@ -30,7 +29,7 @@ class IncidentController extends Controller
} }
/** /**
* Get a single incident * Get a single incident.
* *
* @param int $id * @param int $id
* *
@@ -42,7 +41,7 @@ class IncidentController extends Controller
} }
/** /**
* Create a new incident * Create a new incident.
* *
* @return Incident * @return Incident
*/ */
@@ -52,7 +51,7 @@ class IncidentController extends Controller
} }
/** /**
* Update an existing incident * Update an existing incident.
* *
* @param int $id * @param int $id
* *
@@ -9,7 +9,6 @@ use Input;
class MetricController extends Controller class MetricController extends Controller
{ {
use ControllerTrait; use ControllerTrait;
protected $metric; protected $metric;
@@ -19,7 +18,7 @@ class MetricController extends Controller
$this->metric = $metric; $this->metric = $metric;
} }
/** /**
* Get all metrics * Get all metrics.
* *
* @return \Illuminate\Database\Eloquent\Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
@@ -29,7 +28,7 @@ class MetricController extends Controller
} }
/** /**
* Get a single metric * Get a single metric.
* *
* @param int $id * @param int $id
* *
@@ -41,7 +40,7 @@ class MetricController extends Controller
} }
/** /**
* Create a new metric * Create a new metric.
* *
* @return Metric * @return Metric
*/ */
@@ -51,7 +50,7 @@ class MetricController extends Controller
} }
/** /**
* Update an existing metric * Update an existing metric.
* *
* @param int $id * @param int $id
* *
@@ -9,7 +9,6 @@ use Input;
class MetricPointController extends Controller class MetricPointController extends Controller
{ {
use ControllerTrait; use ControllerTrait;
protected $metricpoint; protected $metricpoint;
@@ -19,7 +18,7 @@ class MetricPointController extends Controller
$this->metricpoint = $metricpoint; $this->metricpoint = $metricpoint;
} }
/** /**
* Get all metric points * Get all metric points.
* *
* @return \Illuminate\Database\Eloquent\Collection * @return \Illuminate\Database\Eloquent\Collection
*/ */
@@ -29,7 +28,7 @@ class MetricPointController extends Controller
} }
/** /**
* Get a single metric point * Get a single metric point.
* *
* @param int $id * @param int $id
* *
@@ -41,7 +40,7 @@ class MetricPointController extends Controller
} }
/** /**
* Create a new metric point * Create a new metric point.
* *
* @return MetricPoint * @return MetricPoint
*/ */
@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\Component;
interface ComponentRepository interface ComponentRepository
{ {
public function all(); public function all();
public function create($id, array $array); public function create($id, array $array);
@@ -7,7 +7,6 @@ use Component;
class EloquentComponentRepository extends EloquentRepository implements ComponentRepository class EloquentComponentRepository extends EloquentRepository implements ComponentRepository
{ {
protected $model; protected $model;
public function __construct(Component $model) public function __construct(Component $model)
@@ -7,9 +7,9 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
abstract class EloquentRepository abstract class EloquentRepository
{ {
/** /**
* Returns all models * Returns all models.
*
* @return object * @return object
*/ */
public function all() public function all()
@@ -18,9 +18,11 @@ abstract class EloquentRepository
} }
/** /**
* Returns an object with related relationships * Returns an object with related relationships.
* @param id $id *
* @param array $with Array of model relationships * @param id $id
* @param array $with Array of model relationships
*
* @return object|ModelNotFoundException * @return object|ModelNotFoundException
*/ */
public function with($id, array $with = []) public function with($id, array $with = [])
@@ -29,9 +31,11 @@ abstract class EloquentRepository
} }
/** /**
* Sets the model to query against a user id * Sets the model to query against a user id.
* @param integer $id *
* @param string $column * @param int $id
* @param string $column
*
* @return $this * @return $this
*/ */
public function withAuth($id, $column = 'user_id') public function withAuth($id, $column = 'user_id')
@@ -42,8 +46,10 @@ abstract class EloquentRepository
} }
/** /**
* Finds a model by ID * Finds a model by ID.
* @param int $id *
* @param int $id
*
* @return object * @return object
*/ */
public function find(int $id) public function find(int $id)
@@ -52,8 +58,10 @@ abstract class EloquentRepository
} }
/** /**
* Finds a model by ID * Finds a model by ID.
* @param integer $id *
* @param int $id
*
* @return object|ModelNotFoundException * @return object|ModelNotFoundException
*/ */
public function findOrFail($id) public function findOrFail($id)
@@ -62,10 +70,12 @@ abstract class EloquentRepository
} }
/** /**
* Finds a model by type * Finds a model by type.
* @param string $key *
* @param string $value * @param string $key
* @param array $columns * @param string $value
* @param array $columns
*
* @return object|ModelNotFoundException * @return object|ModelNotFoundException
*/ */
public function findByOrFail($key, $value, $columns = ['*']) public function findByOrFail($key, $value, $columns = ['*'])
@@ -78,10 +88,12 @@ abstract class EloquentRepository
} }
/** /**
* Counts the number of rows returned * Counts the number of rows returned.
* @param string $key *
* @param string $value * @param string $key
* @return integer * @param string $value
*
* @return int
*/ */
public function count($key = null, $value = null) public function count($key = null, $value = null)
{ {
@@ -93,7 +105,8 @@ abstract class EloquentRepository
} }
/** /**
* Deletes a model by ID * Deletes a model by ID.
*
* @param inetegr $id * @param inetegr $id
*/ */
public function destroy($id) public function destroy($id)
@@ -102,8 +115,10 @@ abstract class EloquentRepository
} }
/** /**
* Validate a given model with Watson validation * Validate a given model with Watson validation.
* @param object $model *
* @param object $model
*
* @return Exception * @return Exception
*/ */
public function validate($model) public function validate($model)
@@ -116,9 +131,11 @@ abstract class EloquentRepository
} }
/** /**
* Validate whether a model has a correct relationship * Validate whether a model has a correct relationship.
* @param object $model *
* @param string $relationship Name of the relationship to validate against * @param object $model
* @param string $relationship Name of the relationship to validate against
*
* @return Exception * @return Exception
*/ */
public function hasRelationship($model, $relationship) public function hasRelationship($model, $relationship)
@@ -7,7 +7,6 @@ use Incident;
class EloquentIncidentRepository extends EloquentRepository implements IncidentRepository class EloquentIncidentRepository extends EloquentRepository implements IncidentRepository
{ {
protected $model; protected $model;
public function __construct(Incident $model) public function __construct(Incident $model)
@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\Incident;
interface IncidentRepository interface IncidentRepository
{ {
public function all(); public function all();
public function create($id, array $array); public function create($id, array $array);
@@ -7,7 +7,6 @@ use Metric;
class EloquentMetricRepository extends EloquentRepository implements MetricRepository class EloquentMetricRepository extends EloquentRepository implements MetricRepository
{ {
protected $model; protected $model;
public function __construct(Metric $model) public function __construct(Metric $model)
@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\Metric;
interface MetricRepository interface MetricRepository
{ {
public function all(); public function all();
public function create(array $array); public function create(array $array);
@@ -7,7 +7,6 @@ use MetricPoint;
class EloquentMetricPointRepository extends EloquentRepository implements MetricRepository class EloquentMetricPointRepository extends EloquentRepository implements MetricRepository
{ {
protected $model; protected $model;
public function __construct(MetricPoint $model) public function __construct(MetricPoint $model)
@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\MetricPoint;
interface MetricPointRepository interface MetricPointRepository
{ {
public function all(); public function all();
public function create(array $array); public function create(array $array);
@@ -7,7 +7,6 @@ use RecursiveDirectoryIterator;
class RoutingServiceProvider extends ServiceProvider class RoutingServiceProvider extends ServiceProvider
{ {
public function register() public function register()
{ {
} }
@@ -18,7 +17,8 @@ class RoutingServiceProvider extends ServiceProvider
} }
/** /**
* Organise Routes * Organise Routes.
*
* @param string $app * @param string $app
*/ */
private function routesInDirectory($app = '') private function routesInDirectory($app = '')
@@ -7,7 +7,6 @@ use League\Fractal\TransformerAbstract;
class ComponentTransformer extends TransformerAbstract class ComponentTransformer extends TransformerAbstract
{ {
public function transform(Component $component) public function transform(Component $component)
{ {
return [ return [
@@ -7,7 +7,6 @@ use League\Fractal\TransformerAbstract;
class IncidentTransformer extends TransformerAbstract class IncidentTransformer extends TransformerAbstract
{ {
public function transform(Incident $incident) public function transform(Incident $incident)
{ {
$component = $incident->component; $component = $incident->component;
@@ -7,7 +7,6 @@ use MetricPoint;
class MetricPointTransformer extends TransformerAbstract class MetricPointTransformer extends TransformerAbstract
{ {
public function transform(MetricPoint $metricPoint) public function transform(MetricPoint $metricPoint)
{ {
return [ return [
@@ -7,7 +7,6 @@ use Metric;
class MetricTransformer extends TransformerAbstract class MetricTransformer extends TransformerAbstract
{ {
public function transform(Metric $metric) public function transform(Metric $metric)
{ {
return [ return [
+3 -1
View File
@@ -4,7 +4,9 @@ class DashAPIController extends Controller
{ {
/** /**
* Updates a component with the entered info. * Updates a component with the entered info.
* @param Component $component *
* @param Component $component
*
* @return array * @return array
*/ */
public function postUpdateComponent(Component $component) public function postUpdateComponent(Component $component)
+1
View File
@@ -11,6 +11,7 @@ class DashboardController extends Controller
{ {
// TODO: Find steps needed to complete setup. // TODO: Find steps needed to complete setup.
$components = Component::all(); $components = Component::all();
return View::make('dashboard.index')->with([ return View::make('dashboard.index')->with([
'components' => $components, 'components' => $components,
]); ]);
+1 -1
View File
@@ -5,7 +5,7 @@ class HomeController extends Controller
/** /**
* The component instance. * The component instance.
* *
* @var \Component $component * @var \Component
*/ */
protected $component; protected $component;
@@ -1,36 +1,33 @@
<?php <?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterTableComponentsAddMetaColumns extends Migration { class AlterTableComponentsAddMetaColumns extends Migration
{
/** /**
* Run the migrations. * Run the migrations.
* *
* @return void * @return void
*/ */
public function up() public function up()
{ {
Schema::table('components', function(Blueprint $table) Schema::table('components', function (Blueprint $table) {
{ $table->text('tags')->nullable()->default(null)->after('description');
$table->text('tags')->nullable()->default(null)->after('description'); $table->text('link')->nullable()->default(null)->after('description');
$table->text('link')->nullable()->default(null)->after('description'); });
}); }
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function(Blueprint $table)
{
$table->dropColumn('tags');
$table->dropColumn('link');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('tags');
$table->dropColumn('link');
});
}
} }
+2 -1
View File
@@ -4,7 +4,8 @@ if (! function_exists('elixir')) {
/** /**
* Get the path to a versioned Elixir file. * Get the path to a versioned Elixir file.
* *
* @param string $file * @param string $file
*
* @return string * @return string
*/ */
function elixir($file) function elixir($file)
+5 -2
View File
@@ -11,7 +11,7 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
'user_id' => 'integer|required', 'user_id' => 'integer|required',
'name' => 'required', 'name' => 'required',
'status' => 'integer', 'status' => 'integer',
'link' => 'url' 'link' => 'url',
]; ];
protected $fillable = [ protected $fillable = [
@@ -20,11 +20,12 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
'status', 'status',
'user_id', 'user_id',
'tags', 'tags',
'link' 'link',
]; ];
/** /**
* Lookup all of the incidents reported on the component. * Lookup all of the incidents reported on the component.
*
* @return Illuminate\Database\Eloquent\Relations * @return Illuminate\Database\Eloquent\Relations
*/ */
public function incidents() public function incidents()
@@ -34,6 +35,7 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
/** /**
* Looks up the human readable version of the status. * Looks up the human readable version of the status.
*
* @return string * @return string
*/ */
public function getHumanStatusAttribute() public function getHumanStatusAttribute()
@@ -43,6 +45,7 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
/** /**
* Get the transformer instance. * Get the transformer instance.
*
* @return ComponentTransformer * @return ComponentTransformer
*/ */
public function getTransformer() public function getTransformer()
+1
View File
@@ -18,6 +18,7 @@ class IncidentTemplate extends Eloquent
/** /**
* Overrides the models boot method. * Overrides the models boot method.
*
* @return void * @return void
*/ */
public static function boot() public static function boot()
+3
View File
@@ -16,6 +16,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/** /**
* Metrics contain many metric points. * Metrics contain many metric points.
*
* @return Illuminate\Database\Eloquent\Builder * @return Illuminate\Database\Eloquent\Builder
*/ */
public function points() public function points()
@@ -25,6 +26,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/** /**
* Determines whether a chart should be shown. * Determines whether a chart should be shown.
*
* @return bool * @return bool
*/ */
public function getShouldDisplayAttribute() public function getShouldDisplayAttribute()
@@ -34,6 +36,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/** /**
* Get the transformer instance. * Get the transformer instance.
*
* @return CachetHQ\Cachet\Transformers\MetricTransformer * @return CachetHQ\Cachet\Transformers\MetricTransformer
*/ */
public function getTransformer() public function getTransformer()
+1
View File
@@ -4,6 +4,7 @@ class MetricPoint extends Eloquent
{ {
/** /**
* A metric point belongs to a metric unit. * A metric point belongs to a metric unit.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function metric() public function metric()
+4 -1
View File
@@ -14,7 +14,9 @@ class Service extends Eloquent
/** /**
* Returns a decoded properties object for the service. * Returns a decoded properties object for the service.
* @param string $properties *
* @param string $properties
*
* @return object * @return object
*/ */
public function getPropertiesAttribute($properties) public function getPropertiesAttribute($properties)
@@ -24,6 +26,7 @@ class Service extends Eloquent
/** /**
* Sets the properties attribute which auto encodes to a JSON string. * Sets the properties attribute which auto encodes to a JSON string.
*
* @param mixed $properties * @param mixed $properties
*/ */
public function setPropertiesAttribute($properties) public function setPropertiesAttribute($properties)
+9 -4
View File
@@ -6,8 +6,10 @@ class Setting extends Eloquent
/** /**
* Returns a setting from the database. * Returns a setting from the database.
* @param string $settingName *
* @param bool $checkEnv * @param string $settingName
* @param bool $checkEnv
*
* @return string * @return string
*/ */
public static function get($settingName, $checkEnv = true) public static function get($settingName, $checkEnv = true)
@@ -33,9 +35,12 @@ class Setting extends Eloquent
} }
/** /**
* Throws an Exception * Throws an Exception.
* @param string $setting *
* @param string $setting
*
* @throws Exception * @throws Exception
*
* @return void * @return void
*/ */
public static function unknownSettingException($setting) public static function unknownSettingException($setting)
+8 -2
View File
@@ -11,26 +11,30 @@ class User extends Eloquent implements UserInterface, RemindableInterface
/** /**
* The database table used by the model. * The database table used by the model.
*
* @var string * @var string
*/ */
protected $table = 'users'; protected $table = 'users';
/** /**
* The attributes excluded from the model's JSON form. * The attributes excluded from the model's JSON form.
*
* @var array * @var array
*/ */
protected $hidden = ['password', 'remember_token']; protected $hidden = ['password', 'remember_token'];
/** /**
* Items which cannot be mass assigned. * Items which cannot be mass assigned.
*
* @var array * @var array
*/ */
protected $guarded = []; protected $guarded = [];
/** /**
* Hash any password being inserted by default * Hash any password being inserted by default.
* *
* @param string @password * @param string @password
*
* @return void * @return void
*/ */
public function setPasswordAttribute($password) public function setPasswordAttribute($password)
@@ -40,7 +44,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface
/** /**
* Returns a Gravatar URL for the users email address. * Returns a Gravatar URL for the users email address.
* @param integer $size *
* @param int $size
*
* @return string * @return string
*/ */
public function getGravatarAttribute($size = 200) public function getGravatarAttribute($size = 200)
+12 -4
View File
@@ -12,6 +12,7 @@ class WebHook extends Eloquent
/** /**
* Returns all responses for a WebHook. * Returns all responses for a WebHook.
*
* @return Illuminate\Database\Eloquent\Builder * @return Illuminate\Database\Eloquent\Builder
*/ */
public function response() public function response()
@@ -21,7 +22,9 @@ class WebHook extends Eloquent
/** /**
* Returns all active hooks. * Returns all active hooks.
* @param Illuminate\Database\Eloquent\Builder $query *
* @param Illuminate\Database\Eloquent\Builder $query
*
* @return Illuminate\Database\Eloquent\Builder * @return Illuminate\Database\Eloquent\Builder
*/ */
public function scopeActive($query) public function scopeActive($query)
@@ -31,6 +34,7 @@ class WebHook extends Eloquent
/** /**
* Setups a Ping event that is fired upon a web hook. * Setups a Ping event that is fired upon a web hook.
*
* @return array result of the ping * @return array result of the ping
*/ */
public function ping() public function ping()
@@ -40,8 +44,10 @@ class WebHook extends Eloquent
/** /**
* Fires the actual web hook event. * Fires the actual web hook event.
* @param string $eventType the event to send X-Cachet-Event *
* @param mixed $data Data to send to the Web Hook * @param string $eventType the event to send X-Cachet-Event
* @param mixed $data Data to send to the Web Hook
*
* @return object * @return object
*/ */
public function fire($eventType, $data = null) public function fire($eventType, $data = null)
@@ -81,8 +87,10 @@ class WebHook extends Eloquent
/** /**
* Returns a human readable request type name. * Returns a human readable request type name.
*
* @throws Exception * @throws Exception
* @return string HEAD, GET, POST, DELETE, PATCH, PUT etc *
* @return string HEAD, GET, POST, DELETE, PATCH, PUT etc
*/ */
public function getRequestMethodAttribute() public function getRequestMethodAttribute()
{ {
+1
View File
@@ -4,6 +4,7 @@ class WebHookResponse extends Eloquent
{ {
/** /**
* Returns the hook that a response belongs to. * Returns the hook that a response belongs to.
*
* @return Illuminate\Database\Eloquent\Relations\BelongsTo * @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/ */
public function hook() public function hook()
+1 -1
View File
@@ -36,7 +36,7 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function () {
// Internal API. // Internal API.
// This should only be used for making requests within the dashboard. // This should only be used for making requests within the dashboard.
Route::group(['prefix' => 'api'], function() { Route::group(['prefix' => 'api'], function () {
Route::post('components/{component}', 'DashAPIController@postUpdateComponent'); Route::post('components/{component}', 'DashAPIController@postUpdateComponent');
}); });
}); });
@@ -2,7 +2,6 @@
class ComponentControllerTest extends TestCase class ComponentControllerTest extends TestCase
{ {
public function setUp() public function setUp()
{ {
$this->repo = Mockery::mock('CachetHQ\Cachet\Repositories\Component\ComponentRepository'); $this->repo = Mockery::mock('CachetHQ\Cachet\Repositories\Component\ComponentRepository');
-1
View File
@@ -2,7 +2,6 @@
class TestCase extends Illuminate\Foundation\Testing\TestCase class TestCase extends Illuminate\Foundation\Testing\TestCase
{ {
/** /**
* Creates the application. * Creates the application.
* *
+1 -2
View File
@@ -1,8 +1,7 @@
<?php <?php
/** /**
* Laravel - A PHP Framework For Web Artisans * Laravel - A PHP Framework For Web Artisans.
* *
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com> * @author Taylor Otwell <taylorotwell@gmail.com>
*/ */