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

View File

@@ -9,7 +9,6 @@ use Input;
class ComponentController extends Controller
{
use ControllerTrait;
protected $component;
@@ -20,7 +19,7 @@ class ComponentController extends Controller
}
/**
* Get all components
* Get all components.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
@@ -30,7 +29,7 @@ class ComponentController extends Controller
}
/**
* Get a single component
* Get a single component.
*
* @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
*
* @return \Component
*/
public function getComponentIncidents($id)
@@ -52,7 +53,7 @@ class ComponentController extends Controller
}
/**
* Create a new component
* Create a new component.
*
* @return \Component
*/

View File

@@ -9,7 +9,6 @@ use Input;
class IncidentController extends Controller
{
use ControllerTrait;
protected $incident;
@@ -20,7 +19,7 @@ class IncidentController extends Controller
}
/**
* Get all incidents
* Get all incidents.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
@@ -30,7 +29,7 @@ class IncidentController extends Controller
}
/**
* Get a single incident
* Get a single incident.
*
* @param int $id
*
@@ -42,7 +41,7 @@ class IncidentController extends Controller
}
/**
* Create a new incident
* Create a new incident.
*
* @return Incident
*/
@@ -52,7 +51,7 @@ class IncidentController extends Controller
}
/**
* Update an existing incident
* Update an existing incident.
*
* @param int $id
*

View File

@@ -9,7 +9,6 @@ use Input;
class MetricController extends Controller
{
use ControllerTrait;
protected $metric;
@@ -19,7 +18,7 @@ class MetricController extends Controller
$this->metric = $metric;
}
/**
* Get all metrics
* Get all metrics.
*
* @return \Illuminate\Database\Eloquent\Collection
*/
@@ -29,7 +28,7 @@ class MetricController extends Controller
}
/**
* Get a single metric
* Get a single metric.
*
* @param int $id
*
@@ -41,7 +40,7 @@ class MetricController extends Controller
}
/**
* Create a new metric
* Create a new metric.
*
* @return Metric
*/
@@ -51,7 +50,7 @@ class MetricController extends Controller
}
/**
* Update an existing metric
* Update an existing metric.
*
* @param int $id
*

View File

@@ -9,7 +9,6 @@ use Input;
class MetricPointController extends Controller
{
use ControllerTrait;
protected $metricpoint;
@@ -19,7 +18,7 @@ class MetricPointController extends Controller
$this->metricpoint = $metricpoint;
}
/**
* Get all metric points
* Get all metric points.
*
* @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
*
@@ -41,7 +40,7 @@ class MetricPointController extends Controller
}
/**
* Create a new metric point
* Create a new metric point.
*
* @return MetricPoint
*/

View File

@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\Component;
interface ComponentRepository
{
public function all();
public function create($id, array $array);

View File

@@ -7,7 +7,6 @@ use Component;
class EloquentComponentRepository extends EloquentRepository implements ComponentRepository
{
protected $model;
public function __construct(Component $model)

View File

@@ -7,9 +7,9 @@ use Illuminate\Database\Eloquent\ModelNotFoundException;
abstract class EloquentRepository
{
/**
* Returns all models
* Returns all models.
*
* @return object
*/
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
*
* @return object|ModelNotFoundException
*/
public function with($id, array $with = [])
@@ -29,9 +31,11 @@ abstract class EloquentRepository
}
/**
* Sets the model to query against a user id
* @param integer $id
* Sets the model to query against a user id.
*
* @param int $id
* @param string $column
*
* @return $this
*/
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
*
* @return object
*/
public function find(int $id)
@@ -52,8 +58,10 @@ abstract class EloquentRepository
}
/**
* Finds a model by ID
* @param integer $id
* Finds a model by ID.
*
* @param int $id
*
* @return object|ModelNotFoundException
*/
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 array $columns
*
* @return object|ModelNotFoundException
*/
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
* @return integer
*
* @return int
*/
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
*/
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
*
* @return Exception
*/
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
*
* @return Exception
*/
public function hasRelationship($model, $relationship)

View File

@@ -7,7 +7,6 @@ use Incident;
class EloquentIncidentRepository extends EloquentRepository implements IncidentRepository
{
protected $model;
public function __construct(Incident $model)

View File

@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\Incident;
interface IncidentRepository
{
public function all();
public function create($id, array $array);

View File

@@ -7,7 +7,6 @@ use Metric;
class EloquentMetricRepository extends EloquentRepository implements MetricRepository
{
protected $model;
public function __construct(Metric $model)

View File

@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\Metric;
interface MetricRepository
{
public function all();
public function create(array $array);

View File

@@ -7,7 +7,6 @@ use MetricPoint;
class EloquentMetricPointRepository extends EloquentRepository implements MetricRepository
{
protected $model;
public function __construct(MetricPoint $model)

View File

@@ -4,7 +4,6 @@ namespace CachetHQ\Cachet\Repositories\MetricPoint;
interface MetricPointRepository
{
public function all();
public function create(array $array);

View File

@@ -7,7 +7,6 @@ use RecursiveDirectoryIterator;
class RoutingServiceProvider extends ServiceProvider
{
public function register()
{
}
@@ -18,7 +17,8 @@ class RoutingServiceProvider extends ServiceProvider
}
/**
* Organise Routes
* Organise Routes.
*
* @param string $app
*/
private function routesInDirectory($app = '')

View File

@@ -7,7 +7,6 @@ use League\Fractal\TransformerAbstract;
class ComponentTransformer extends TransformerAbstract
{
public function transform(Component $component)
{
return [

View File

@@ -7,7 +7,6 @@ use League\Fractal\TransformerAbstract;
class IncidentTransformer extends TransformerAbstract
{
public function transform(Incident $incident)
{
$component = $incident->component;

View File

@@ -7,7 +7,6 @@ use MetricPoint;
class MetricPointTransformer extends TransformerAbstract
{
public function transform(MetricPoint $metricPoint)
{
return [

View File

@@ -7,7 +7,6 @@ use Metric;
class MetricTransformer extends TransformerAbstract
{
public function transform(Metric $metric)
{
return [

View File

@@ -4,7 +4,9 @@ class DashAPIController extends Controller
{
/**
* Updates a component with the entered info.
*
* @param Component $component
*
* @return array
*/
public function postUpdateComponent(Component $component)

View File

@@ -11,6 +11,7 @@ class DashboardController extends Controller
{
// TODO: Find steps needed to complete setup.
$components = Component::all();
return View::make('dashboard.index')->with([
'components' => $components,
]);

View File

@@ -5,7 +5,7 @@ class HomeController extends Controller
/**
* The component instance.
*
* @var \Component $component
* @var \Component
*/
protected $component;

View File

@@ -1,10 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterTableComponentsAddMetaColumns extends Migration {
class AlterTableComponentsAddMetaColumns extends Migration
{
/**
* Run the migrations.
*
@@ -12,8 +12,7 @@ class AlterTableComponentsAddMetaColumns extends Migration {
*/
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('link')->nullable()->default(null)->after('description');
});
@@ -26,11 +25,9 @@ class AlterTableComponentsAddMetaColumns extends Migration {
*/
public function down()
{
Schema::table('components', function(Blueprint $table)
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('tags');
$table->dropColumn('link');
});
}
}

View File

@@ -5,6 +5,7 @@ if (! function_exists('elixir')) {
* Get the path to a versioned Elixir file.
*
* @param string $file
*
* @return string
*/
function elixir($file)

View File

@@ -11,7 +11,7 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
'user_id' => 'integer|required',
'name' => 'required',
'status' => 'integer',
'link' => 'url'
'link' => 'url',
];
protected $fillable = [
@@ -20,11 +20,12 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
'status',
'user_id',
'tags',
'link'
'link',
];
/**
* Lookup all of the incidents reported on the component.
*
* @return Illuminate\Database\Eloquent\Relations
*/
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.
*
* @return string
*/
public function getHumanStatusAttribute()
@@ -43,6 +45,7 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
/**
* Get the transformer instance.
*
* @return ComponentTransformer
*/
public function getTransformer()

View File

@@ -18,6 +18,7 @@ class IncidentTemplate extends Eloquent
/**
* Overrides the models boot method.
*
* @return void
*/
public static function boot()

View File

@@ -16,6 +16,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/**
* Metrics contain many metric points.
*
* @return Illuminate\Database\Eloquent\Builder
*/
public function points()
@@ -25,6 +26,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/**
* Determines whether a chart should be shown.
*
* @return bool
*/
public function getShouldDisplayAttribute()
@@ -34,6 +36,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
/**
* Get the transformer instance.
*
* @return CachetHQ\Cachet\Transformers\MetricTransformer
*/
public function getTransformer()

View File

@@ -4,6 +4,7 @@ class MetricPoint extends Eloquent
{
/**
* A metric point belongs to a metric unit.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function metric()

View File

@@ -14,7 +14,9 @@ class Service extends Eloquent
/**
* Returns a decoded properties object for the service.
*
* @param string $properties
*
* @return object
*/
public function getPropertiesAttribute($properties)
@@ -24,6 +26,7 @@ class Service extends Eloquent
/**
* Sets the properties attribute which auto encodes to a JSON string.
*
* @param mixed $properties
*/
public function setPropertiesAttribute($properties)

View File

@@ -6,8 +6,10 @@ class Setting extends Eloquent
/**
* Returns a setting from the database.
*
* @param string $settingName
* @param bool $checkEnv
*
* @return string
*/
public static function get($settingName, $checkEnv = true)
@@ -33,9 +35,12 @@ class Setting extends Eloquent
}
/**
* Throws an Exception
* Throws an Exception.
*
* @param string $setting
*
* @throws Exception
*
* @return void
*/
public static function unknownSettingException($setting)

View File

@@ -11,26 +11,30 @@ class User extends Eloquent implements UserInterface, RemindableInterface
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'users';
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = ['password', 'remember_token'];
/**
* Items which cannot be mass assigned.
*
* @var array
*/
protected $guarded = [];
/**
* Hash any password being inserted by default
* Hash any password being inserted by default.
*
* @param string @password
*
* @return void
*/
public function setPasswordAttribute($password)
@@ -40,7 +44,9 @@ class User extends Eloquent implements UserInterface, RemindableInterface
/**
* Returns a Gravatar URL for the users email address.
* @param integer $size
*
* @param int $size
*
* @return string
*/
public function getGravatarAttribute($size = 200)

View File

@@ -12,6 +12,7 @@ class WebHook extends Eloquent
/**
* Returns all responses for a WebHook.
*
* @return Illuminate\Database\Eloquent\Builder
*/
public function response()
@@ -21,7 +22,9 @@ class WebHook extends Eloquent
/**
* Returns all active hooks.
*
* @param Illuminate\Database\Eloquent\Builder $query
*
* @return Illuminate\Database\Eloquent\Builder
*/
public function scopeActive($query)
@@ -31,6 +34,7 @@ class WebHook extends Eloquent
/**
* Setups a Ping event that is fired upon a web hook.
*
* @return array result of the ping
*/
public function ping()
@@ -40,8 +44,10 @@ class WebHook extends Eloquent
/**
* 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
*
* @return object
*/
public function fire($eventType, $data = null)
@@ -81,7 +87,9 @@ class WebHook extends Eloquent
/**
* Returns a human readable request type name.
*
* @throws Exception
*
* @return string HEAD, GET, POST, DELETE, PATCH, PUT etc
*/
public function getRequestMethodAttribute()

View File

@@ -4,6 +4,7 @@ class WebHookResponse extends Eloquent
{
/**
* Returns the hook that a response belongs to.
*
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function hook()

View File

@@ -2,7 +2,6 @@
class ComponentControllerTest extends TestCase
{
public function setUp()
{
$this->repo = Mockery::mock('CachetHQ\Cachet\Repositories\Component\ComponentRepository');

View File

@@ -2,7 +2,6 @@
class TestCase extends Illuminate\Foundation\Testing\TestCase
{
/**
* Creates the application.
*

View File

@@ -1,8 +1,7 @@
<?php
/**
* Laravel - A PHP Framework For Web Artisans
* Laravel - A PHP Framework For Web Artisans.
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/