This commit is contained in:
Graham Campbell
2014-12-20 21:20:17 +00:00
parent 26e4361d8a
commit 9d8d89248f
103 changed files with 2478 additions and 2353 deletions

View File

@@ -2,18 +2,20 @@
namespace CachetHQ\Cachet\Controllers\Api;
use Input;
use CachetHQ\Cachet\Repositories\Component\ComponentRepository;
use Dingo\Api\Routing\ControllerTrait;
use Illuminate\Routing\Controller;
use CachetHQ\Cachet\Repositories\Component\ComponentRepository;
use Input;
class ComponentController extends Controller {
class ComponentController extends Controller
{
use ControllerTrait;
protected $component;
public function __construct(ComponentRepository $component) {
public function __construct(ComponentRepository $component)
{
$this->component = $component;
}
@@ -22,7 +24,8 @@ class ComponentController extends Controller {
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getComponents() {
public function getComponents()
{
return $this->component->all();
}
@@ -33,7 +36,8 @@ class ComponentController extends Controller {
*
* @return \Component
*/
public function getComponent($id) {
public function getComponent($id)
{
return $this->component->findOrFail($id);
}
@@ -42,7 +46,8 @@ class ComponentController extends Controller {
* @param int $id Component ID
* @return \Component
*/
public function getComponentIncidents($id) {
public function getComponentIncidents($id)
{
return $this->component->with($id, ['incidents']);
}
@@ -51,7 +56,8 @@ class ComponentController extends Controller {
*
* @return \Component
*/
public function postComponents() {
public function postComponents()
{
return $this->component->create($this->auth->user()->id, Input::all());
}
}

View File

@@ -2,18 +2,20 @@
namespace CachetHQ\Cachet\Controllers\Api;
use Input;
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
use Dingo\Api\Routing\ControllerTrait;
use Illuminate\Routing\Controller;
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
use Input;
class IncidentController extends Controller {
class IncidentController extends Controller
{
use ControllerTrait;
protected $incident;
public function __construct(IncidentRepository $incident) {
public function __construct(IncidentRepository $incident)
{
$this->incident = $incident;
}
@@ -22,7 +24,8 @@ class IncidentController extends Controller {
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getIncidents() {
public function getIncidents()
{
return $this->incident->all();
}
@@ -33,7 +36,8 @@ class IncidentController extends Controller {
*
* @return Incident
*/
public function getIncident($id) {
public function getIncident($id)
{
return $this->incident->findOrFail($id);
}
@@ -42,7 +46,8 @@ class IncidentController extends Controller {
*
* @return Incident
*/
public function postIncidents() {
public function postIncidents()
{
return $this->incident->create($this->auth->user()->id, Input::all());
}
@@ -53,7 +58,8 @@ class IncidentController extends Controller {
*
* @return Incident
*/
public function putIncident($id) {
public function putIncident($id)
{
return $this->incident->update($id, Input::all());
}
}

View File

@@ -2,18 +2,20 @@
namespace CachetHQ\Cachet\Controllers\Api;
use Input;
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
use Dingo\Api\Routing\ControllerTrait;
use Illuminate\Routing\Controller;
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
use Input;
class MetricController extends Controller {
class MetricController extends Controller
{
use ControllerTrait;
protected $metric;
public function __construct(MetricRepository $metric) {
public function __construct(MetricRepository $metric)
{
$this->metric = $metric;
}
/**
@@ -21,7 +23,8 @@ class MetricController extends Controller {
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getMetrics() {
public function getMetrics()
{
return $this->metric->all();
}
@@ -32,7 +35,8 @@ class MetricController extends Controller {
*
* @return Metric
*/
public function getMetric($id) {
public function getMetric($id)
{
return $this->metric->findOrFail($id);
}
@@ -41,7 +45,8 @@ class MetricController extends Controller {
*
* @return Metric
*/
public function postMetrics() {
public function postMetrics()
{
return $this->metric->create(Input::all());
}
@@ -52,7 +57,8 @@ class MetricController extends Controller {
*
* @return Metric
*/
public function putMetric($id) {
public function putMetric($id)
{
return $this->metric->update($id, Input::all());
}
}

View File

@@ -2,18 +2,20 @@
namespace CachetHQ\Cachet\Controllers\Api;
use Input;
use CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository;
use Dingo\Api\Routing\ControllerTrait;
use Illuminate\Routing\Controller;
use CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository;
use Input;
class MetricController extends Controller {
class MetricPointController extends Controller
{
use ControllerTrait;
protected $metricpoint;
public function __construct(MetricPointRepository $metricpoint) {
public function __construct(MetricPointRepository $metricpoint)
{
$this->metricpoint = $metricpoint;
}
/**
@@ -21,7 +23,8 @@ class MetricController extends Controller {
*
* @return \Illuminate\Database\Eloquent\Collection
*/
public function getMetricPoints() {
public function getMetricPoints()
{
return $this->metricpoint->all();
}
@@ -32,7 +35,8 @@ class MetricController extends Controller {
*
* @return MetricPoint
*/
public function getMetricPoint($id) {
public function getMetricPoint($id)
{
return $this->metricpoint->findOrFail($id);
}
@@ -41,7 +45,8 @@ class MetricController extends Controller {
*
* @return MetricPoint
*/
public function postMetricPoints() {
public function postMetricPoints()
{
return $this->metricpoint->create(Input::all());
}
}

View File

@@ -2,7 +2,8 @@
namespace CachetHQ\Cachet\Repositories\Component;
interface ComponentRepository {
interface ComponentRepository
{
public function all();

View File

@@ -4,23 +4,26 @@ namespace CachetHQ\Cachet\Repositories\Component;
use CachetHQ\Cachet\Repositories\EloquentRepository;
use Component;
use Exception;
class EloquentComponentRepository extends EloquentRepository implements ComponentRepository {
class EloquentComponentRepository extends EloquentRepository implements ComponentRepository
{
protected $model;
public function __construct(Component $model) {
public function __construct(Component $model)
{
$this->model = $model;
}
public function create($user_id, array $array) {
public function create($user_id, array $array)
{
$component = new $this->model($array);
$component->user_id = $user_id;
$this->validate($component);
$component->saveOrFail();
return $component;
}
}

View File

@@ -2,16 +2,18 @@
namespace CachetHQ\Cachet\Repositories;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
abstract class EloquentRepository {
abstract class EloquentRepository
{
/**
* Returns all models
* @return object
*/
public function all() {
public function all()
{
return $this->model->all();
}
@@ -21,7 +23,8 @@ abstract class EloquentRepository {
* @param array $with Array of model relationships
* @return object|ModelNotFoundException
*/
public function with($id, array $with = []) {
public function with($id, array $with = [])
{
return $this->model->with($with)->findOrFail($id);
}
@@ -31,8 +34,10 @@ abstract class EloquentRepository {
* @param string $column
* @return $this
*/
public function withAuth($id, $column = 'user_id') {
public function withAuth($id, $column = 'user_id')
{
$this->model = $this->model->where($column, $id);
return $this;
}
@@ -41,7 +46,8 @@ abstract class EloquentRepository {
* @param int $id
* @return object
*/
public function find(int $id) {
public function find(int $id)
{
return $this->model->find($id);
}
@@ -50,7 +56,8 @@ abstract class EloquentRepository {
* @param integer $id
* @return object|ModelNotFoundException
*/
public function findOrFail($id) {
public function findOrFail($id)
{
return $this->model->findOrFail($id);
}
@@ -61,12 +68,13 @@ abstract class EloquentRepository {
* @param array $columns
* @return object|ModelNotFoundException
*/
public function findByOrFail($key, $value, $columns = ['*']) {
public function findByOrFail($key, $value, $columns = ['*'])
{
if (! is_null($item = $this->model->where($key, $value)->first($columns))) {
return $item;
}
throw new ModelNotFoundException;
throw new ModelNotFoundException();
}
/**
@@ -75,7 +83,8 @@ abstract class EloquentRepository {
* @param string $value
* @return integer
*/
public function count($key = null, $value = null) {
public function count($key = null, $value = null)
{
if (is_null($key) || is_null($value)) {
return $this->model->where($key, $value)->count();
}
@@ -87,7 +96,8 @@ abstract class EloquentRepository {
* Deletes a model by ID
* @param inetegr $id
*/
public function destroy($id) {
public function destroy($id)
{
$this->model->delete($id);
}
@@ -96,7 +106,8 @@ abstract class EloquentRepository {
* @param object $model
* @return Exception
*/
public function validate($model) {
public function validate($model)
{
if ($model->isInvalid()) {
throw new Exception('Invalid model validation');
}
@@ -110,7 +121,8 @@ abstract class EloquentRepository {
* @param string $relationship Name of the relationship to validate against
* @return Exception
*/
public function hasRelationship($model, $relationship) {
public function hasRelationship($model, $relationship)
{
if (! $model->$relationship) {
throw new Exception('Invalid relationship exception');
}

View File

@@ -5,31 +5,37 @@ namespace CachetHQ\Cachet\Repositories\Incident;
use CachetHQ\Cachet\Repositories\EloquentRepository;
use Incident;
class EloquentIncidentRepository extends EloquentRepository implements IncidentRepository {
class EloquentIncidentRepository extends EloquentRepository implements IncidentRepository
{
protected $model;
public function __construct(Incident $model) {
public function __construct(Incident $model)
{
$this->model = $model;
}
public function create($user_id, array $array) {
public function create($user_id, array $array)
{
$incident = new $this->model($array);
$incident->user_id = $user_id;
$this->validate($incident)->hasRelationship($incident, 'component');
$incident->saveOrFail();
return $incident;
}
public function update($id, array $array) {
public function update($id, array $array)
{
$incident = $this->model->findOrFail($id);
$incident->fill($array);
$this->validate($incident)->hasRelationship($incident, 'component');
$incident->update($array);
return $incident;
}
}

View File

@@ -2,7 +2,8 @@
namespace CachetHQ\Cachet\Repositories\Incident;
interface IncidentRepository {
interface IncidentRepository
{
public function all();

View File

@@ -5,30 +5,36 @@ namespace CachetHQ\Cachet\Repositories\Metric;
use CachetHQ\Cachet\Repositories\EloquentRepository;
use Metric;
class EloquentMetricRepository extends EloquentRepository implements MetricRepository {
class EloquentMetricRepository extends EloquentRepository implements MetricRepository
{
protected $model;
public function __construct(Metric $model) {
public function __construct(Metric $model)
{
$this->model = $model;
}
public function create(array $array) {
public function create(array $array)
{
$metric = new $this->model($array);
$this->validate($metric);
$metric->saveOrFail();
return $metric;
}
public function update($id, array $array) {
public function update($id, array $array)
{
$metric = $this->model->findOrFail($id);
$metric->fill($array);
$this->validate($metric);
$metric->update($array);
return $metric;
}
}

View File

@@ -2,7 +2,8 @@
namespace CachetHQ\Cachet\Repositories\Metric;
interface MetricRepository {
interface MetricRepository
{
public function all();

View File

@@ -5,30 +5,36 @@ namespace CachetHQ\Cachet\Repositories\MetricPoint;
use CachetHQ\Cachet\Repositories\EloquentRepository;
use MetricPoint;
class EloquentMetricRepository extends EloquentRepository implements MetricRepository {
class EloquentMetricPointRepository extends EloquentRepository implements MetricRepository
{
protected $model;
public function __construct(MetricPoint $model) {
public function __construct(MetricPoint $model)
{
$this->model = $model;
}
public function create(array $array) {
public function create(array $array)
{
$metric = new $this->model($array);
$this->validate($metric);
$metric->saveOrFail();
return $metric;
}
public function update($id, array $array) {
public function update($id, array $array)
{
$metric = $this->model->findOrFail($id);
$metric->fill($array);
$this->validate($metric);
$metric->update($array);
return $metric;
}
}

View File

@@ -2,7 +2,8 @@
namespace CachetHQ\Cachet\Repositories\MetricPoint;
interface MetricPointRepository {
interface MetricPointRepository
{
public function all();

View File

@@ -2,18 +2,19 @@
namespace CachetHQ\Cachet\Service\Email;
class EmailService implements ServiceInterface {
class EmailService implements ServiceInterface
{
protected $properties;
public function register() {
public function register()
{
}
public function unregister() {
public function unregister()
{
}
public function fire($data) {
public function fire($data)
{
}
}

View File

@@ -2,7 +2,8 @@
namespace CachetHQ\Cachet\Service;
interface ServiceInterface {
interface ServiceInterface
{
public function register();
public function unregister();
public function fire($data);

View File

@@ -4,8 +4,10 @@ namespace CachetHQ\Cachet\Support\ServiceProviders;
use Illuminate\Support\ServiceProvider;
class RepositoryServiceProvider extends ServiceProvider {
public function register() {
class RepositoryServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind(
'CachetHQ\Cachet\Repositories\Component\ComponentRepository',
'CachetHQ\Cachet\Repositories\Component\EloquentComponentRepository'

View File

@@ -5,11 +5,15 @@ namespace CachetHQ\Cachet\Support\ServiceProviders;
use Illuminate\Support\ServiceProvider;
use RecursiveDirectoryIterator;
class RoutingServiceProvider extends ServiceProvider {
class RoutingServiceProvider extends ServiceProvider
{
public function register() {}
public function register()
{
}
public function boot() {
public function boot()
{
$this->routesInDirectory();
}
@@ -17,8 +21,9 @@ class RoutingServiceProvider extends ServiceProvider {
* Organise Routes
* @param string $app
*/
private function routesInDirectory($app = '') {
$routeDir = app_path('routes/' . $app . ($app !== '' ? '/' : null));
private function routesInDirectory($app = '')
{
$routeDir = app_path('routes/'.$app.($app !== '' ? '/' : null));
$iterator = new RecursiveDirectoryIterator($routeDir);
$iterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
@@ -27,9 +32,8 @@ class RoutingServiceProvider extends ServiceProvider {
$isDotFile = strpos($route->getFilename(), '.') === 0;
if (!$isDotFile && !$route->isDir()) {
require $routeDir . $route->getFilename();
require $routeDir.$route->getFilename();
}
}
}
}

View File

@@ -5,9 +5,11 @@ namespace CachetHQ\Cachet\Transformers;
use Component;
use League\Fractal\TransformerAbstract;
class ComponentTransformer extends TransformerAbstract {
class ComponentTransformer extends TransformerAbstract
{
public function transform(Component $component) {
public function transform(Component $component)
{
return [
'id' => (int) $component->id,
'name' => $component->name,
@@ -19,5 +21,4 @@ class ComponentTransformer extends TransformerAbstract {
'updated_at' => $component->updated_at->timestamp,
];
}
}

View File

@@ -5,9 +5,11 @@ namespace CachetHQ\Cachet\Transformers;
use Incident;
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;
$transformer = $component->getTransformer();

View File

@@ -2,12 +2,14 @@
namespace CachetHQ\Cachet\Transformers;
use MetricPoint;
use League\Fractal\TransformerAbstract;
use MetricPoint;
class MetricPointTransformer extends TransformerAbstract {
class MetricPointTransformer extends TransformerAbstract
{
public function transform(MetricPoint $metricPoint) {
public function transform(MetricPoint $metricPoint)
{
return [
'id' => (int) $metricPoint->id,
'metric_id' => $metricPoint->metric_id,
@@ -16,5 +18,4 @@ class MetricPointTransformer extends TransformerAbstract {
'updated_at' => $metricPoint->updated_at->timestamp,
];
}
}

View File

@@ -2,12 +2,14 @@
namespace CachetHQ\Cachet\Transformers;
use Metric;
use League\Fractal\TransformerAbstract;
use Metric;
class MetricTransformer extends TransformerAbstract {
class MetricTransformer extends TransformerAbstract
{
public function transform(Metric $metric) {
public function transform(Metric $metric)
{
return [
'id' => (int) $metric->id,
'name' => $metric->name,
@@ -18,5 +20,4 @@ class MetricTransformer extends TransformerAbstract {
'updated_at' => $metric->updated_at->timestamp,
];
}
}

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -93,7 +93,7 @@ return array(
|
*/
'providers' => array(
'providers' => [
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
@@ -128,7 +128,7 @@ return array(
'CachetHQ\Cachet\Support\ServiceProviders\RepositoryServiceProvider',
'CachetHQ\Cachet\Support\ServiceProviders\RoutingServiceProvider',
),
],
/*
|--------------------------------------------------------------------------
@@ -154,7 +154,7 @@ return array(
|
*/
'aliases' => array(
'aliases' => [
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
@@ -199,6 +199,6 @@ return array(
'API' => 'Dingo\Api\Facade\API',
'RSS' => 'Thujohn\Rss\RssFacade',
),
],
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -58,7 +58,7 @@ return array(
|
*/
'reminder' => array(
'reminder' => [
'email' => 'emails.auth.reminder',
@@ -66,6 +66,6 @@ return array(
'expire' => 60,
),
],
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -67,11 +67,11 @@ return array(
|
*/
'memcached' => array(
'memcached' => [
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
['host' => '127.0.0.1', 'port' => 11211, 'weight' => 100],
),
],
/*
|--------------------------------------------------------------------------
@@ -86,4 +86,4 @@ return array(
'prefix' => 'laravel',
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -13,6 +13,4 @@ return array(
|
*/
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -44,15 +44,15 @@ return array(
|
*/
'connections' => array(
'connections' => [
'sqlite' => array(
'sqlite' => [
'driver' => 'sqlite',
'database' => __DIR__.'/../database/'.$_ENV['DB_DATABASE'],
'prefix' => '',
),
],
'mysql' => array(
'mysql' => [
'driver' => 'mysql',
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_DATABASE'],
@@ -61,9 +61,9 @@ return array(
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
],
'pgsql' => array(
'pgsql' => [
'driver' => 'pgsql',
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_DATABASE'],
@@ -72,18 +72,18 @@ return array(
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
),
],
'sqlsrv' => array(
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => $_ENV['DB_HOST'],
'database' => $_ENV['DB_DATABASE'],
'username' => $_ENV['DB_USERNAME'],
'password' => $_ENV['DB_PASSWORD'],
'prefix' => '',
),
],
),
],
/*
|--------------------------------------------------------------------------
@@ -109,16 +109,16 @@ return array(
|
*/
'redis' => array(
'redis' => [
'cluster' => false,
'default' => array(
'default' => [
'host' => '127.0.0.1',
'port' => 6379,
'database' => 0,
),
],
),
],
);
];

View File

@@ -3,10 +3,10 @@
$dbURL = parse_url(getenv('CLEARDB_DATABASE_URL'));
$dbName = substr($dbURL["path"], 1);
return array(
return [
'default' => 'cleardb',
'connections' => array(
'cleardb' => array(
'connections' => [
'cleardb' => [
'driver' => 'mysql',
'host' => $dbURL['host'],
'database' => $dbName,
@@ -15,6 +15,6 @@ return array(
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
)
);
],
],
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -17,4 +17,4 @@ return array(
'url' => 'http://cachet.io.dev',
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -54,7 +54,7 @@ return array(
|
*/
'from' => array('address' => null, 'name' => null),
'from' => ['address' => null, 'name' => null],
/*
|--------------------------------------------------------------------------
@@ -121,4 +121,4 @@ return array(
'pretend' => false,
);
];

View File

@@ -78,7 +78,7 @@ return [
'auth' => [
'basic' => function ($app) {
return new Dingo\Api\Auth\BasicProvider($app['auth']);
}
},
],
/*
@@ -101,15 +101,15 @@ return [
'authenticated' => [
'limit' => 0,
'reset' => 60
'reset' => 60,
],
'unauthenticated' => [
'limit' => 0,
'reset' => 60
'reset' => 60,
],
'exceeded' => 'API rate limit has been exceeded.'
'exceeded' => 'API rate limit has been exceeded.',
],
@@ -126,7 +126,7 @@ return [
*/
'transformer' => function ($app) {
$fractal = new League\Fractal\Manager;
$fractal = new League\Fractal\Manager();
return new Dingo\Api\Transformer\FractalTransformer($fractal);
},
@@ -146,7 +146,7 @@ return [
'formats' => [
'json' => new Dingo\Api\Http\ResponseFormat\JsonResponseFormat
'json' => new Dingo\Api\Http\ResponseFormat\JsonResponseFormat(),
]

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -28,42 +28,42 @@ return array(
|
*/
'connections' => array(
'connections' => [
'sync' => array(
'sync' => [
'driver' => 'sync',
),
],
'beanstalkd' => array(
'beanstalkd' => [
'driver' => 'beanstalkd',
'host' => 'localhost',
'queue' => 'default',
'ttr' => 60,
),
],
'sqs' => array(
'sqs' => [
'driver' => 'sqs',
'key' => 'your-public-key',
'secret' => 'your-secret-key',
'queue' => 'your-queue-url',
'region' => 'us-east-1',
),
],
'iron' => array(
'iron' => [
'driver' => 'iron',
'host' => 'mq-aws-us-east-1.iron.io',
'token' => 'your-token',
'project' => 'your-project-id',
'queue' => 'your-queue-name',
'encrypt' => true,
),
],
'redis' => array(
'redis' => [
'driver' => 'redis',
'queue' => 'default',
),
],
),
],
/*
|--------------------------------------------------------------------------
@@ -76,10 +76,10 @@ return array(
|
*/
'failed' => array(
'failed' => [
'database' => 'mysql', 'table' => 'failed_jobs',
),
],
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -26,18 +26,18 @@ return array(
|
*/
'connections' => array(
'connections' => [
'production' => array(
'production' => [
'host' => '',
'username' => '',
'password' => '',
'key' => '',
'keyphrase' => '',
'root' => '/var/www',
),
],
),
],
/*
|--------------------------------------------------------------------------
@@ -50,10 +50,10 @@ return array(
|
*/
'groups' => array(
'groups' => [
'web' => array('production')
'web' => ['production'],
),
],
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -14,18 +14,18 @@ return array(
|
*/
'mailgun' => array(
'mailgun' => [
'domain' => '',
'secret' => '',
),
],
'mandrill' => array(
'mandrill' => [
'secret' => '',
),
],
'stripe' => array(
'stripe' => [
'model' => 'User',
'secret' => '',
),
],
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -83,7 +83,7 @@ return array(
|
*/
'lottery' => array(2, 100),
'lottery' => [2, 100],
/*
|--------------------------------------------------------------------------
@@ -137,4 +137,4 @@ return array(
'secure' => false,
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -17,4 +17,4 @@ return array(
'driver' => 'array',
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -18,4 +18,4 @@ return array(
'driver' => 'array',
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -13,7 +13,7 @@ return array(
|
*/
'paths' => array(__DIR__.'/../views'),
'paths' => [__DIR__.'/../views'],
/*
|--------------------------------------------------------------------------
@@ -28,4 +28,4 @@ return array(
'pagination' => 'pagination::slider-3',
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -28,4 +28,4 @@ return array(
'email' => '',
);
];

View File

@@ -3,12 +3,14 @@
/**
* Logs users into their account
*/
class AuthController extends Controller {
class AuthController extends Controller
{
/**
* Shows the login view.
* @return \Illuminate\View\View
*/
public function showLogin() {
public function showLogin()
{
return View::make('auth.login');
}
@@ -16,7 +18,8 @@ class AuthController extends Controller {
* Logs the user in.
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin() {
public function postLogin()
{
if (Auth::attempt(Input::only(['email', 'password']))) {
return Redirect::intended('dashboard');
} else {
@@ -30,8 +33,10 @@ class AuthController extends Controller {
* Logs the user out, deleting their session etc.
* @return \Illuminate\Http\RedirectResponse
*/
public function logoutAction() {
public function logoutAction()
{
Auth::logout();
return Redirect::to('/');
}
}

View File

@@ -1,16 +1,18 @@
<?php
class DashComponentController extends Controller {
class DashComponentController extends Controller
{
/**
* Shows the components view.
* @return \Illuminate\View\View
*/
public function showComponents() {
public function showComponents()
{
$components = Component::all();
return View::make('dashboard.components')->with([
'pageTitle' => 'Components - Dashboard',
'components' => $components
'components' => $components,
]);
}
@@ -19,11 +21,11 @@ class DashComponentController extends Controller {
* @param Component $component
* @return \Illuminate\View\View
*/
public function showEditComponent(Component $component) {
public function showEditComponent(Component $component)
{
return View::make('dashboard.component-edit')->with([
'pageTitle' => 'Editing "' . $component->name . '" Component - Dashboard',
'component' => $component
'pageTitle' => 'Editing "'.$component->name.'" Component - Dashboard',
'component' => $component,
]);
}
@@ -31,7 +33,8 @@ class DashComponentController extends Controller {
* Updates a component.
* @return \Illuminate\Http\RedirectResponse
*/
public function updateComponentAction(Component $component) {
public function updateComponentAction(Component $component)
{
$_component = Input::get('component');
$component->update($_component);
@@ -42,7 +45,8 @@ class DashComponentController extends Controller {
* Shows the add component view.
* @return \Illuminate\View\View
*/
public function showAddComponent() {
public function showAddComponent()
{
return View::make('dashboard.component-add')->with([
'pageTitle' => 'Add Component - Dashboard',
]);
@@ -52,7 +56,8 @@ class DashComponentController extends Controller {
* Creates a new component.
* @return \Illuminate\Http\RedirectResponse
*/
public function createComponentAction() {
public function createComponentAction()
{
$_component = Input::get('component');
$component = Component::create($_component);
@@ -64,8 +69,10 @@ class DashComponentController extends Controller {
* @param Component $component
* @return \Illuminate\Http\RedirectResponse
*/
public function deleteComponentAction(Component $component) {
public function deleteComponentAction(Component $component)
{
$component->delete();
return Redirect::back();
}
}

View File

@@ -1,16 +1,18 @@
<?php
class DashIncidentController extends Controller {
class DashIncidentController extends Controller
{
/**
* Shows the incidents view.
* @return \Illuminate\View\View
*/
public function showIncidents() {
public function showIncidents()
{
$incidents = Incident::all();
return View::make('dashboard.incidents')->with([
'pageTitle' => 'Incidents - Dashboard',
'incidents' => $incidents
'incidents' => $incidents,
]);
}
@@ -18,7 +20,8 @@ class DashIncidentController extends Controller {
* Shows the add incident view.
* @return \Illuminate\View\View
*/
public function showAddIncident() {
public function showAddIncident()
{
return View::make('dashboard.incident-add')->with([
'pageTitle' => 'Add Incident - Dashboard',
]);
@@ -28,7 +31,8 @@ class DashIncidentController extends Controller {
* Shows the add incident template view.
* @return \Illuminate\View\View
*/
public function showAddIncidentTemplate() {
public function showAddIncidentTemplate()
{
return View::make('dashboard.incident-template')->with([
'pageTitle' => 'Add Incident Template - Dashboard',
]);
@@ -38,7 +42,8 @@ class DashIncidentController extends Controller {
* Creates a new incident template.
* @return \Illuminate\Http\RedirectResponse
*/
public function createIncidentTemplateAction() {
public function createIncidentTemplateAction()
{
$_template = Input::get('template');
$template = IncidentTemplate::create($_template);
@@ -49,7 +54,8 @@ class DashIncidentController extends Controller {
* Creates a new incident.
* @return \Illuminate\Http\RedirectResponse
*/
public function createIncidentAction() {
public function createIncidentAction()
{
$_incident = Input::get('incident');
$incident = Incident::create($_incident);

View File

@@ -1,13 +1,15 @@
<?php
class DashSettingsController extends Controller {
class DashSettingsController extends Controller
{
/**
* Shows the settings view.
* @return \Illuminate\View\View
*/
public function showSettings() {
public function showSettings()
{
return View::make('dashboard.settings')->with([
'pageTitle' => 'Settings - Dashboard'
'pageTitle' => 'Settings - Dashboard',
]);
}
@@ -15,7 +17,8 @@ class DashSettingsController extends Controller {
* Updates the statsu page settings.
* @return \Illuminate\View\View
*/
public function postSettings() {
public function postSettings()
{
$settings = Input::all();
foreach ($settings as $settingName => $settingValue) {
@@ -31,7 +34,7 @@ class DashSettingsController extends Controller {
$setting = Setting::firstOrCreate([
'name' => $settingName,
])->update([
'value' => $settingValue
'value' => $settingValue,
]);
}

View File

@@ -1,11 +1,13 @@
<?php
class DashboardController extends Controller {
class DashboardController extends Controller
{
/**
* Shows the dashboard view.
* @return \Illuminate\View\View
*/
public function showDashboard() {
public function showDashboard()
{
return View::make('dashboard.index');
}
@@ -13,9 +15,10 @@ class DashboardController extends Controller {
* Shows the metrics view.
* @return \Illuminate\View\View
*/
public function showMetrics() {
public function showMetrics()
{
return View::make('dashboard.metrics')->with([
'pageTitle' => 'Metrics - Dashboard'
'pageTitle' => 'Metrics - Dashboard',
]);
}
@@ -23,9 +26,10 @@ class DashboardController extends Controller {
* Shows the notifications view.
* @return \Illuminate\View\View
*/
public function showNotifications() {
public function showNotifications()
{
return View::make('dashboard.notifications')->with([
'pageTitle' => 'Notifications - Dashboard'
'pageTitle' => 'Notifications - Dashboard',
]);
}
}

View File

@@ -1,12 +1,14 @@
<?php
class HomeController extends Controller {
class HomeController extends Controller
{
/**
* @var Component $component
*/
protected $component;
public function __construct(Component $component) {
public function __construct(Component $component)
{
$this->component = $component;
}
@@ -14,7 +16,8 @@ class HomeController extends Controller {
* Returns the rendered Blade templates.
* @return \Illuminate\View\View
*/
public function showIndex() {
public function showIndex()
{
return View::make('index', ['components' => $this->component->all()]);
}
}

View File

@@ -1,11 +1,13 @@
<?php
class RSSController extends Controller {
class RSSController extends Controller
{
/**
* Generates an RSS feed of all incidents.
* @return \Illuminate\Http\Response
*/
public function feedAction() {
public function feedAction()
{
$feed = RSS::feed('2.0', 'UTF-8');
$feed->channel([
'title' => Setting::get('app_name'),
@@ -13,7 +15,7 @@ class RSSController extends Controller {
'link' => Setting::get('app_domain'),
]);
Incident::get()->map(function($incident) use ($feed) {
Incident::get()->map(function ($incident) use ($feed) {
$componentName = null;
$component = $incident->component;
if ($component) {
@@ -26,7 +28,7 @@ class RSSController extends Controller {
'component' => $componentName,
'status' => $incident->humanStatus,
'created_at' => $incident->created_at,
'updated_at' => $incident->updated_at
'updated_at' => $incident->updated_at,
]);
});

View File

@@ -1,7 +1,9 @@
<?php
class SetupController extends Controller {
public function __construct() {
class SetupController extends Controller
{
public function __construct()
{
$this->beforeFilter('csrf', ['only' => ['postCachet']]);
}
@@ -9,9 +11,10 @@ class SetupController extends Controller {
* Returns the setup page.
* @return \Illuminate\View\View
*/
public function getIndex() {
public function getIndex()
{
return View::make('setup')->with([
'pageTitle' => 'Setup'
'pageTitle' => 'Setup',
]);
}
@@ -19,7 +22,8 @@ class SetupController extends Controller {
* Handles the actual app setup.
* @return \Illuminate\Http\RedirectResponse
*/
public function postIndex() {
public function postIndex()
{
$postData = Input::get();
$v = Validator::make($postData, [
@@ -47,7 +51,7 @@ class SetupController extends Controller {
$settings = array_get($postData, 'settings');
foreach ($settings as $settingName => $settingValue) {
$setting = new Setting;
$setting = new Setting();
$setting->name = $settingName;
$setting->value = $settingValue;
$setting->save();

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateIncidentsTable extends Migration {
class CreateIncidentsTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateIncidentsTable extends Migration {
*/
public function up()
{
Schema::create('incidents', function(Blueprint $table)
{
Schema::create('incidents', function (Blueprint $table) {
$table->increments('id');
$table->tinyInteger('component')->default(1);
$table->string('name');
@@ -36,5 +36,4 @@ class CreateIncidentsTable extends Migration {
{
Schema::drop('incidents');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateComponentsTable extends Migration {
class CreateComponentsTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateComponentsTable extends Migration {
*/
public function up()
{
Schema::create('components', function(Blueprint $table)
{
Schema::create('components', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('description')->nullable()->default(null);
@@ -33,5 +33,4 @@ class CreateComponentsTable extends Migration {
{
Schema::drop('components');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateSettingsTable extends Migration {
class CreateSettingsTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateSettingsTable extends Migration {
*/
public function up()
{
Schema::create('settings', function(Blueprint $table)
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('value')->nullable()->default(null);
@@ -30,5 +30,4 @@ class CreateSettingsTable extends Migration {
{
Schema::drop('settings');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateWebHooksTable extends Migration {
class CreateWebHooksTable extends Migration
{
/**
* Run the migrations.
@@ -12,11 +13,10 @@ class CreateWebHooksTable extends Migration {
*/
public function up()
{
Schema::create('web_hooks', function(Blueprint $table)
{
Schema::create('web_hooks', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable(FALSE);
$table->string('endpoint')->nullable(FALSE);
$table->string('name')->nullable(false);
$table->string('endpoint')->nullable(false);
$table->tinyInteger('hook_type')->default(0); // When should this web hook be called?
$table->tinyInteger('request_type')->default(0); // ENUM: GET, POST, PUT, DELETE etc
$table->boolean('active')->default(0);
@@ -37,5 +37,4 @@ class CreateWebHooksTable extends Migration {
{
Schema::drop('web_hooks');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateWebHookResponsesTable extends Migration {
class CreateWebHookResponsesTable extends Migration
{
/**
* Run the migrations.
@@ -12,11 +13,10 @@ class CreateWebHookResponsesTable extends Migration {
*/
public function up()
{
Schema::create('web_hook_response', function(Blueprint $table)
{
Schema::create('web_hook_response', function (Blueprint $table) {
$table->increments('id');
$table->integer('hook_id')->unsigned();
$table->tinyInteger('response_code')->nullable(FALSE); // This should return something like 200, 301 etc.
$table->tinyInteger('response_code')->nullable(false); // This should return something like 200, 301 etc.
$table->string('response_type'); // application/json etc.
$table->text('sent_headers');
$table->longText('sent_body'); // What we sent the web hook
@@ -38,5 +38,4 @@ class CreateWebHookResponsesTable extends Migration {
{
Schema::drop('web_hook_response');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateUsersTable extends Migration {
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateUsersTable extends Migration {
*/
public function up()
{
Schema::create('users', function(Blueprint $table)
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username', 200)->nullable(false);
$table->string('password')->nullable(false);
@@ -37,5 +37,4 @@ class CreateUsersTable extends Migration {
{
Schema::drop('users');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateIncidentTemplatesTable extends Migration {
class CreateIncidentTemplatesTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateIncidentTemplatesTable extends Migration {
*/
public function up()
{
Schema::create('incident_templates', function(Blueprint $table)
{
Schema::create('incident_templates', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable(false);
$table->string('slug', 50)->nullable(false);
@@ -34,5 +34,4 @@ class CreateIncidentTemplatesTable extends Migration {
{
Schema::drop('incident_templates');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateMetricsTable extends Migration {
class CreateMetricsTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateMetricsTable extends Migration {
*/
public function up()
{
Schema::create('metrics', function(Blueprint $table)
{
Schema::create('metrics', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->nullable(false);
$table->string('suffix')->nullable(false);
@@ -32,5 +32,4 @@ class CreateMetricsTable extends Migration {
{
Schema::drop('metrics');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateMetricPointsTable extends Migration {
class CreateMetricPointsTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateMetricPointsTable extends Migration {
*/
public function up()
{
Schema::create('metric_points', function(Blueprint $table)
{
Schema::create('metric_points', function (Blueprint $table) {
$table->increments('id');
$table->integer('metric_id')->unsigned();
$table->integer('value')->unsigned();
@@ -32,5 +32,4 @@ class CreateMetricPointsTable extends Migration {
{
Schema::drop('metric_points');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UserIdColumnForComponents extends Migration {
class UserIdColumnForComponents extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class UserIdColumnForComponents extends Migration {
*/
public function up()
{
Schema::table('components', function(Blueprint $table)
{
Schema::table('components', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('NO ACTION');
@@ -27,10 +27,8 @@ class UserIdColumnForComponents extends Migration {
*/
public function down()
{
Schema::table('components', function(Blueprint $table)
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('user_id');
});
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class UserIdColumnForIncidents extends Migration {
class UserIdColumnForIncidents extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class UserIdColumnForIncidents extends Migration {
*/
public function up()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
$table->unsignedInteger('user_id')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('NO ACTION');
@@ -27,10 +27,8 @@ class UserIdColumnForIncidents extends Migration {
*/
public function down()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
$table->dropColumn('user_id');
});
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateSubscribersTable extends Migration {
class CreateSubscribersTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateSubscribersTable extends Migration {
*/
public function up()
{
Schema::create('subscribers', function(Blueprint $table)
{
Schema::create('subscribers', function (Blueprint $table) {
$table->increments('id');
$table->string('email')->nullable(false);
$table->timestamps();
@@ -30,5 +30,4 @@ class CreateSubscribersTable extends Migration {
{
Schema::drop('subscribers');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateServicesTable extends Migration {
class CreateServicesTable extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class CreateServicesTable extends Migration {
*/
public function up()
{
Schema::create('services', function(Blueprint $table)
{
Schema::create('services', function (Blueprint $table) {
$table->increments('id');
$table->string('type')->nullable(false);
@@ -33,5 +33,4 @@ class CreateServicesTable extends Migration {
{
Schema::drop('services');
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterTableIncidentsRenameComponentColumn extends Migration {
class AlterTableIncidentsRenameComponentColumn extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class AlterTableIncidentsRenameComponentColumn extends Migration {
*/
public function up()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
DB::statement("ALTER TABLE `incidents` CHANGE `component` `component_id` TINYINT(4) NOT NULL DEFAULT '1'");
});
}
@@ -25,10 +25,8 @@ class AlterTableIncidentsRenameComponentColumn extends Migration {
*/
public function down()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
DB::statement("ALTER TABLE `incidents` CHANGE `component_id` `component` TINYINT(4) NOT NULL DEFAULT '1'");
});
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterIncidentsTableMoveUserIdColumn extends Migration {
class AlterIncidentsTableMoveUserIdColumn extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class AlterIncidentsTableMoveUserIdColumn extends Migration {
*/
public function up()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
DB::statement('ALTER TABLE `incidents` MODIFY COLUMN `user_id` INT(10) UNSIGNED DEFAULT NULL AFTER `component_id`;');
});
}
@@ -25,11 +25,9 @@ class AlterIncidentsTableMoveUserIdColumn extends Migration {
*/
public function down()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
DB::statement('ALTER TABLE `incidents` MODIFY COLUMN `user_id` INT(10) UNSIGNED DEFAULT NULL AFTER `deleted_at`;');
});
}
}

View File

@@ -1,9 +1,10 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterTableIncidentsRemoveDefaultComponent extends Migration {
class AlterTableIncidentsRemoveDefaultComponent extends Migration
{
/**
* Run the migrations.
@@ -12,8 +13,7 @@ class AlterTableIncidentsRemoveDefaultComponent extends Migration {
*/
public function up()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
DB::statement("ALTER TABLE `incidents` CHANGE `component_id` `component_id` TINYINT(4) NOT NULL DEFAULT '0';");
});
}
@@ -25,10 +25,8 @@ class AlterTableIncidentsRemoveDefaultComponent extends Migration {
*/
public function down()
{
Schema::table('incidents', function(Blueprint $table)
{
Schema::table('incidents', function (Blueprint $table) {
DB::statement("ALTER TABLE `incidents` CHANGE `component_id` `component_id` TINYINT(4) NOT NULL DEFAULT '1';");
});
}
}

View File

@@ -2,7 +2,8 @@
use Illuminate\Database\Migrations\Migration;
class CreateSessionTable extends Migration {
class CreateSessionTable extends Migration
{
/**
* Run the migrations.
@@ -11,8 +12,7 @@ class CreateSessionTable extends Migration {
*/
public function up()
{
Schema::create('sessions', function($t)
{
Schema::create('sessions', function ($t) {
$t->string('id')->unique();
$t->text('payload');
$t->integer('last_activity');
@@ -28,5 +28,4 @@ class CreateSessionTable extends Migration {
{
Schema::drop('sessions');
}
}

View File

@@ -1,17 +1,19 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AlterTableComponentsAddDeletedAt extends Migration {
class AlterTableComponentsAddDeletedAt extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up() {
Schema::table('components', function(Blueprint $table) {
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->softDeletes();
});
}
@@ -24,5 +26,4 @@ class AlterTableComponentsAddDeletedAt extends Migration {
public function down()
{
}
}

View File

@@ -1,6 +1,7 @@
<?php
class ComponentTableSeeder extends Seeder {
class ComponentTableSeeder extends Seeder
{
/**
* Run the database seeds.
@@ -16,7 +17,7 @@ class ComponentTableSeeder extends Seeder {
"name" => "API",
"description" => "Used by third-parties to connect to us",
"status" => 1,
"user_id" => 1
"user_id" => 1,
], [
"name" => "Payments",
"description" => "Backed by Stripe",
@@ -26,12 +27,12 @@ class ComponentTableSeeder extends Seeder {
"name" => "Website",
"status" => 1,
"user_id" => 1
]
],
];
Component::truncate();
foreach($defaultComponents as $component) {
foreach ($defaultComponents as $component) {
Component::create($component);
}
}

View File

@@ -1,6 +1,7 @@
<?php
class DatabaseSeeder extends Seeder {
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
@@ -15,5 +16,4 @@ class DatabaseSeeder extends Seeder {
$this->call('IncidentTableSeeder');
$this->call('ComponentTableSeeder');
}
}

View File

@@ -1,6 +1,7 @@
<?php
class IncidentTableSeeder extends Seeder {
class IncidentTableSeeder extends Seeder
{
/**
* Run the database seeds.
@@ -38,12 +39,12 @@ class IncidentTableSeeder extends Seeder {
"status" => 4,
"component_id" => 2,
"user_id" => 1,
]
],
];
Incident::truncate();
foreach($defaultIncidents as $incident) {
foreach ($defaultIncidents as $incident) {
Incident::create($incident);
}
}

View File

@@ -1,6 +1,7 @@
<?php
class SettingsTableSeeder extends Seeder {
class SettingsTableSeeder extends Seeder
{
/**
* Run the database seeds.
@@ -14,13 +15,13 @@ class SettingsTableSeeder extends Seeder {
$defaultSettings = [
[
"name" => "site_name",
"value" => "Test"
]
"value" => "Test",
],
];
Setting::truncate();
foreach($defaultSettings as $setting) {
foreach ($defaultSettings as $setting) {
Setting::create($setting);
}
}

View File

@@ -16,7 +16,7 @@ Route::filter('allowed_domains', 'AllowedDomainsFilter');
|
*/
Route::filter('auth', function() {
Route::filter('auth', function () {
if (Auth::guest()) {
if (Request::ajax()) {
return Response::make('Unauthorized', 401);
@@ -26,8 +26,7 @@ Route::filter('auth', function() {
}
});
Route::filter('auth.basic', function() {
Route::filter('auth.basic', function () {
return Auth::basic();
});
@@ -42,7 +41,7 @@ Route::filter('auth.basic', function() {
|
*/
Route::filter('guest', function() {
Route::filter('guest', function () {
if (Auth::check()) {
return Redirect::to('/');
}
@@ -59,8 +58,8 @@ Route::filter('guest', function() {
|
*/
Route::filter('csrf', function() {
Route::filter('csrf', function () {
if (Session::token() !== Input::get('_token')) {
throw new Illuminate\Session\TokenMismatchException;
throw new Illuminate\Session\TokenMismatchException();
}
});

View File

@@ -1,7 +1,9 @@
<?php
class AllowedDomainsFilter {
public function filter($route, $request, $response) {
class AllowedDomainsFilter
{
public function filter($route, $request, $response)
{
// Always allow our own domain.
$ourDomain = Setting::get('app_domain');
$response->headers->set('Access-Control-Allow-Origin', $ourDomain);

View File

@@ -1,8 +1,11 @@
<?php
class CORSFilter {
public function filter($route, $request, $response) {
class CORSFilter
{
public function filter($route, $request, $response)
{
$response->headers->set('Access-Control-Allow-Origin', '*');
return $response;
}
}

View File

@@ -1,7 +1,9 @@
<?php
class HasSettingFilter {
public function filter($route, $request, $settingName) {
class HasSettingFilter
{
public function filter($route, $request, $settingName)
{
try {
$setting = Setting::where('name', $settingName)->first();
if (!$setting->value) {

View File

@@ -1,7 +1,9 @@
<?php
class IsSetupFilter {
public function filter($route, $request) {
class IsSetupFilter
{
public function filter($route, $request)
{
try {
$setting = Setting::where('name', 'app_name')->first();
if ($setting->value) {

View File

@@ -1,7 +1,6 @@
<?php
if ( ! function_exists('elixir'))
{
if (! function_exists('elixir')) {
/**
* Get the path to a versioned Elixir file.
*
@@ -12,17 +11,14 @@ if ( ! function_exists('elixir'))
{
static $manifest = null;
if (is_null($manifest))
{
if (is_null($manifest)) {
$manifest = json_decode(file_get_contents(public_path().'/build/rev-manifest.json'), true);
}
if (isset($manifest[$file]))
{
if (isset($manifest[$file])) {
return '/build/'.$manifest[$file];
}
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}

View File

@@ -1,35 +1,35 @@
<?php
return array(
return [
// Components
'component' => array(
'status' => array(
'component' => [
'status' => [
1 => 'Operational',
2 => 'Performance Issues',
3 => 'Partial Outage',
4 => 'Major Outage'
)
),
4 => 'Major Outage',
],
],
// Incidents
'incident' => array(
'status' => array(
'incident' => [
'status' => [
1 => 'Investigating',
2 => 'Identified',
3 => 'Watching',
4 => 'Fixed'
)
),
4 => 'Fixed',
],
],
// Service Status
'service' => array(
'service' => [
'good' => 'All systems are functional.',
'bad' => 'Some systems are experiencing issues.',
),
],
// Other
'powered_by' => ':app Status Page is powered by <a href="https://cachethq.github.io">Cachet</a>.',
'logout' => 'Logout',
'logged_in' => 'You\'re logged in.',
'setup' => 'Setup Cachet',
'dashboard' => array(
'dashboard' => [
'dashboard' => 'Dashboard',
'components' => 'Components',
'component-add' => 'Add Component',
@@ -43,5 +43,5 @@ return array(
'notifications' => 'Notifications',
'toggle_navigation' => 'Toggle Navigation',
'search' => 'Search...',
),
);
],
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -17,4 +17,4 @@ return array(
'next' => 'Next &raquo;',
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -23,4 +23,4 @@ return array(
"reset" => "Password has been reset!",
);
];

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -21,12 +21,12 @@ return array(
"alpha_num" => "The :attribute may only contain letters and numbers.",
"array" => "The :attribute must be an array.",
"before" => "The :attribute must be a date before :date.",
"between" => array(
"between" => [
"numeric" => "The :attribute must be between :min and :max.",
"file" => "The :attribute must be between :min and :max kilobytes.",
"string" => "The :attribute must be between :min and :max characters.",
"array" => "The :attribute must have between :min and :max items.",
),
],
"boolean" => "The :attribute field must be true or false.",
"confirmed" => "The :attribute confirmation does not match.",
"date" => "The :attribute is not a valid date.",
@@ -40,19 +40,19 @@ return array(
"in" => "The selected :attribute is invalid.",
"integer" => "The :attribute must be an integer.",
"ip" => "The :attribute must be a valid IP address.",
"max" => array(
"max" => [
"numeric" => "The :attribute may not be greater than :max.",
"file" => "The :attribute may not be greater than :max kilobytes.",
"string" => "The :attribute may not be greater than :max characters.",
"array" => "The :attribute may not have more than :max items.",
),
],
"mimes" => "The :attribute must be a file of type: :values.",
"min" => array(
"min" => [
"numeric" => "The :attribute must be at least :min.",
"file" => "The :attribute must be at least :min kilobytes.",
"string" => "The :attribute must be at least :min characters.",
"array" => "The :attribute must have at least :min items.",
),
],
"not_in" => "The selected :attribute is invalid.",
"numeric" => "The :attribute must be a number.",
"regex" => "The :attribute format is invalid.",
@@ -63,12 +63,12 @@ return array(
"required_without" => "The :attribute field is required when :values is not present.",
"required_without_all" => "The :attribute field is required when none of :values are present.",
"same" => "The :attribute and :other must match.",
"size" => array(
"size" => [
"numeric" => "The :attribute must be :size.",
"file" => "The :attribute must be :size kilobytes.",
"string" => "The :attribute must be :size characters.",
"array" => "The :attribute must contain :size items.",
),
],
"unique" => "The :attribute has already been taken.",
"url" => "The :attribute format is invalid.",
"timezone" => "The :attribute must be a valid zone.",
@@ -84,11 +84,11 @@ return array(
|
*/
'custom' => array(
'attribute-name' => array(
'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
),
),
],
],
/*
|--------------------------------------------------------------------------
@@ -101,6 +101,6 @@ return array(
|
*/
'attributes' => array(),
'attributes' => [],
);
];

View File

@@ -2,14 +2,15 @@
use Watson\Validating\ValidatingTrait;
class Component extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
class Component extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface
{
use ValidatingTrait;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
protected $rules = [
'user_id' => 'integer|required',
'name' => 'required',
'status' => 'integer'
'status' => 'integer',
];
protected $fillable = ['name', 'description', 'status', 'user_id'];
@@ -18,7 +19,8 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
* Lookup all of the incidents reported on the component.
* @return Illuminate\Database\Eloquent\Relations
*/
public function incidents() {
public function incidents()
{
return $this->hasMany('Incident', 'component_id', 'id');
}
@@ -26,15 +28,17 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
* Looks up the human readable version of the status.
* @return string
*/
public function getHumanStatusAttribute() {
return Lang::get('cachet.component.status.' . $this->status);
public function getHumanStatusAttribute()
{
return Lang::get('cachet.component.status.'.$this->status);
}
/**
* Get the transformer instance.
* @return ComponentTransformer
*/
public function getTransformer() {
public function getTransformer()
{
return new CachetHQ\Cachet\Transformers\ComponentTransformer();
}
}

View File

@@ -2,7 +2,8 @@
use Watson\Validating\ValidatingTrait;
class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface
{
use ValidatingTrait;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
@@ -22,7 +23,8 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
* An incident belongs to a component.
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function component() {
public function component()
{
return $this->belongsTo('Component', 'component_id', 'id');
}
@@ -30,8 +32,10 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
* Returns a human readable version of the status.
* @return string
*/
public function getHumanStatusAttribute() {
public function getHumanStatusAttribute()
{
$statuses = Lang::get('cachet.incident.status');
return $statuses[$this->status];
}
@@ -39,7 +43,8 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
* Finds the icon to use for each status.
* @return string
*/
public function getIconAttribute() {
public function getIconAttribute()
{
switch ($this->status) {
case 1: return 'fa fa-flag';
case 2: return 'fa fa-warning';
@@ -52,7 +57,8 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
* Get the transformer instance.
* @return CachetHQ\Cachet\Transformers\IncidentTransformer
*/
public function getTransformer() {
public function getTransformer()
{
return new CachetHQ\Cachet\Transformers\IncidentTransformer();
}
}

View File

@@ -2,7 +2,8 @@
use Watson\Validating\ValidatingTrait;
class IncidentTemplate extends Eloquent {
class IncidentTemplate extends Eloquent
{
use ValidatingTrait;
protected $rules = [
@@ -19,10 +20,11 @@ class IncidentTemplate extends Eloquent {
* Overrides the models boot method.
* @return void
*/
public static function boot() {
public static function boot()
{
parent::boot();
self::saving(function($template) {
self::saving(function ($template) {
$template->slug = Str::slug($template->name);
});
}

View File

@@ -2,7 +2,8 @@
use Watson\Validating\ValidatingTrait;
class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface {
class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface
{
use ValidatingTrait;
protected $rules = [
@@ -17,7 +18,8 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
* Metrics contain many metric points.
* @return Illuminate\Database\Eloquent\Builder
*/
public function points() {
public function points()
{
return $this->hasMany('MetricPoint', 'metric_id', 'id');
}
@@ -25,7 +27,8 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
* Determines whether a chart should be shown.
* @return bool
*/
public function getShouldDisplayAttribute() {
public function getShouldDisplayAttribute()
{
return $this->display_chart === 1;
}
@@ -33,7 +36,8 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
* Get the transformer instance.
* @return CachetHQ\Cachet\Transformers\MetricTransformer
*/
public function getTransformer() {
public function getTransformer()
{
return new CachetHQ\Cachet\Transformers\MetricTransformer();
}
}

View File

@@ -1,11 +1,13 @@
<?php
class MetricPoint extends Eloquent {
class MetricPoint extends Eloquent
{
/**
* A metric point belongs to a metric unit.
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function metric() {
public function metric()
{
return $this->belongsTo('Metric', 'id', 'metric_id');
}
}

View File

@@ -2,13 +2,14 @@
use Watson\Validating\ValidatingTrait;
class Service extends Eloquent {
class Service extends Eloquent
{
use ValidatingTrait;
protected $rules = [
'type' => 'alpha_dash|required',
'active' => 'required|in:0,1',
'properties' => ''
'properties' => '',
];
/**
@@ -16,7 +17,8 @@ class Service extends Eloquent {
* @param string $properties
* @return object
*/
public function getPropertiesAttribute($properties) {
public function getPropertiesAttribute($properties)
{
return json_decode($properties);
}
@@ -24,7 +26,8 @@ class Service extends Eloquent {
* Sets the properties attribute which auto encodes to a JSON string.
* @param mixed $properties
*/
public function setPropertiesAttribute($properties) {
public function setPropertiesAttribute($properties)
{
$this->attributes['properties'] = json_encode($properties);
}
}

View File

@@ -1,6 +1,7 @@
<?php
class Setting extends Eloquent {
class Setting extends Eloquent
{
protected $fillable = ['name', 'value'];
/**
@@ -9,7 +10,8 @@ class Setting extends Eloquent {
* @param bool $checkEnv
* @return string
*/
public static function get($settingName, $checkEnv = true) {
public static function get($settingName, $checkEnv = true)
{
// Default setting value.
$setting = null;
@@ -36,7 +38,8 @@ class Setting extends Eloquent {
* @throws Exception
* @return void
*/
public static function unknownSettingException($setting) {
public static function unknownSettingException($setting)
{
throw new \Exception(
sprintf('Unknown setting %s', $setting)
);

View File

@@ -1,14 +1,15 @@
<?php
use Watson\Validating\ValidatingTrait;
use Illuminate\Database\Eloquent\SoftDeletingTrait;
use Watson\Validating\ValidatingTrait;
class Subscriber extends Eloquent {
class Subscriber extends Eloquent
{
use ValidatingTrait;
use SoftDeletingTrait;
protected $rules = [
'email' => 'required|email'
'email' => 'required|email',
];
protected $fillable = ['email'];

View File

@@ -1,11 +1,12 @@
<?php
use Illuminate\Auth\UserTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\Reminders\RemindableInterface;
use Illuminate\Auth\Reminders\RemindableTrait;
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\UserTrait;
class User extends Eloquent implements UserInterface, RemindableInterface {
class User extends Eloquent implements UserInterface, RemindableInterface
{
use UserTrait, RemindableTrait;
/**
@@ -32,7 +33,8 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
* @param string @password
* @return void
*/
public function setPasswordAttribute($password) {
public function setPasswordAttribute($password)
{
$this->attributes['password'] = Hash::make($password);
}
@@ -41,12 +43,12 @@ class User extends Eloquent implements UserInterface, RemindableInterface {
* @param integer $size
* @return string
*/
public function getGravatarAttribute($size = 200) {
public function getGravatarAttribute($size = 200)
{
return sprintf(
'https://www.gravatar.com/avatar/%s?size=%d',
md5($this->email),
$size
);
}
}

View File

@@ -1,6 +1,7 @@
<?php
class WebHook extends Eloquent {
class WebHook extends Eloquent
{
// Request Methods.
const HEAD = 0;
const GET = 1;
@@ -13,7 +14,8 @@ class WebHook extends Eloquent {
* Returns all responses for a WebHook.
* @return Illuminate\Database\Eloquent\Builder
*/
public function response() {
public function response()
{
return $this->hasMany('WebHookContent', 'hook_id', 'id');
}
@@ -22,7 +24,8 @@ class WebHook extends Eloquent {
* @param Illuminate\Database\Eloquent\Builder $query
* @return Illuminate\Database\Eloquent\Builder
*/
public function scopeActive($query) {
public function scopeActive($query)
{
return $query->where('active', 1);
}
@@ -30,7 +33,8 @@ class WebHook extends Eloquent {
* Setups a Ping event that is fired upon a web hook.
* @return array result of the ping
*/
public function ping() {
public function ping()
{
return $this->fire('ping', 'Coming live to you from Cachet.');
}
@@ -40,7 +44,8 @@ class WebHook extends Eloquent {
* @param mixed $data Data to send to the Web Hook
* @return object
*/
public function fire($eventType, $data = null) {
public function fire($eventType, $data = null)
{
$startTime = microtime(true);
$client = new \GuzzleHttp\Client();
@@ -58,10 +63,10 @@ class WebHook extends Eloquent {
$response = $e->getResponse();
}
$timeTaken = microtime(TRUE) - $startTime;
$timeTaken = microtime(true) - $startTime;
// Store the request
$hookResponse = new WebHookResponse;
$hookResponse = new WebHookResponse();
$hookResponse->web_hook_id = $this->id;
$hookResponse->response_code = $response->getStatusCode();
$hookResponse->sent_headers = json_encode($request->getHeaders());
@@ -79,8 +84,9 @@ class WebHook extends Eloquent {
* @throws Exception
* @return string HEAD, GET, POST, DELETE, PATCH, PUT etc
*/
public function getRequestMethodAttribute() {
$requestMethod = NULL;
public function getRequestMethodAttribute()
{
$requestMethod = null;
switch ($this->request_type) {
case self::HEAD:
@@ -103,7 +109,7 @@ class WebHook extends Eloquent {
break;
default:
throw new Exception('Unknown request type value: ' . $this->request_type);
throw new Exception('Unknown request type value: '.$this->request_type);
break;
}

View File

@@ -1,11 +1,13 @@
<?php
class WebHookResponse extends Eloquent {
class WebHookResponse extends Eloquent
{
/**
* Returns the hook that a response belongs to.
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function hook() {
public function hook()
{
return $this->belongsTo('WebHook', 'id', 'hook_id');
}
}

View File

@@ -3,8 +3,8 @@
Route::api([
'version' => 'v1',
'namespace' => 'CachetHQ\Cachet\Controllers\Api',
'after' => 'allowed_domains'
], function() {
'after' => 'allowed_domains',
], function () {
Route::get('components', 'ComponentController@getComponents');
Route::get('components/{id}', 'ComponentController@getComponent');
Route::get('components/{id}/incidents', 'ComponentController@getComponentIncidents');
@@ -14,7 +14,7 @@ Route::api([
Route::get('metrics/{id}', 'MetricController@getMetric');
Route::get('metrics/points/{id}', 'MetricPointController@getMetricPoint');
Route::group(['protected' => true], function() {
Route::group(['protected' => true], function () {
Route::post('components', 'ComponentController@postComponents');
Route::post('incidents', 'IncidentController@postIncidents');
Route::post('metrics', 'MetricController@postMetrics');

View File

@@ -1,13 +1,13 @@
<?php
// Prevent access until the app is setup.
Route::group(['before' => 'has_setting:app_name'], function() {
Route::group(['before' => 'has_setting:app_name'], function () {
Route::get('/', ['as' => 'status-page', 'uses' => 'HomeController@showIndex']);
Route::get('/incident/{incident}', 'HomeController@showIncident');
});
// Setup route.
Route::group(['before' => 'is_setup'], function() {
Route::group(['before' => 'is_setup'], function () {
Route::controller('/setup', 'SetupController');
});

View File

@@ -1,6 +1,6 @@
<?php
Route::group(['before' => 'has_setting:app_name'], function() {
Route::group(['before' => 'has_setting:app_name'], function () {
Route::get('/auth/login', ['before' => 'guest', 'as' => 'login', 'uses' => 'AuthController@showLogin']);
Route::post('/auth/login', ['before' => 'guest|csrf', 'as' => 'logout', 'uses' => 'AuthController@postLogin']);
});

View File

@@ -1,6 +1,6 @@
<?php
Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function() {
Route::group(['before' => 'auth', 'prefix' => 'dashboard'], function () {
// Dashboard
Route::get('/', ['as' => 'dashboard', 'uses' => 'DashboardController@showDashboard']);

View File

@@ -10,4 +10,3 @@
| the console gets access to each of the command object instances.
|
*/

View File

@@ -11,7 +11,7 @@
|
*/
ClassLoader::addDirectories(array(
ClassLoader::addDirectories([
app_path().'/commands',
app_path().'/controllers',
@@ -20,7 +20,7 @@ ClassLoader::addDirectories(array(
app_path().'/database/seeds',
app_path().'/filters',
));
]);
/*
|--------------------------------------------------------------------------
@@ -48,8 +48,7 @@ Log::useFiles(storage_path().'/logs/laravel.log');
|
*/
App::error(function(Exception $exception, $code)
{
App::error(function (Exception $exception, $code) {
Log::error($exception);
});
@@ -57,8 +56,8 @@ API::error(function (\Illuminate\Database\Eloquent\ModelNotFoundException $excep
return Response::make(['error' => $exception->getMessage()], 404);
});
App::missing(function($exception) {
return Response::view('errors.404', array(), 404);
App::missing(function ($exception) {
return Response::view('errors.404', [], 404);
});
/*
@@ -72,8 +71,7 @@ App::missing(function($exception) {
|
*/
App::down(function()
{
App::down(function () {
return Response::make("Be right back!", 503);
});

View File

@@ -1,17 +1,21 @@
<?php
class ComponentControllerTest extends TestCase {
class ComponentControllerTest extends TestCase
{
public function setUp() {
public function setUp()
{
$this->repo = Mockery::mock('CachetHQ\Cachet\Repositories\Component\ComponentRepository');
$this->dingo = Mockery::mock('Dingo\Api\Auth\Shield');
}
public function tearDown() {
public function tearDown()
{
Mockery::close();
}
public function test_get_components_method() {
public function test_get_components_method()
{
$this->repo->shouldReceive('all')->once()->andReturn('foo');
$controller = new CachetHQ\Cachet\Controllers\Api\ComponentController($this->repo);
@@ -20,7 +24,8 @@ class ComponentControllerTest extends TestCase {
$this->assertEquals('foo', $response);
}
public function test_get_component_method() {
public function test_get_component_method()
{
$this->repo->shouldReceive('findOrFail')->with(1)->once()->andReturn('foo');
$controller = new CachetHQ\Cachet\Controllers\Api\ComponentController($this->repo);
@@ -28,5 +33,4 @@ class ComponentControllerTest extends TestCase {
$this->assertEquals('foo', $response);
}
}

View File

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

View File

@@ -1,9 +1,9 @@
<?php
View::composer('index', function($view) {
View::composer('index', function ($view) {
$date = date('Y-m-d');
$incidents = Incident::whereRaw('DATE(created_at) = "' . $date . '"')
$incidents = Incident::whereRaw('DATE(created_at) = "'.$date.'"')
->groupBy('status')
->orderBy('status', 'desc');
@@ -19,6 +19,6 @@ View::composer('index', function($view) {
$view->with([
'systemStatus' => $status,
'systemMessage' => $message
'systemMessage' => $message,
]);
});

View File

@@ -27,8 +27,7 @@ require __DIR__.'/../vendor/autoload.php';
|
*/
if (file_exists($compiled = __DIR__.'/compiled.php'))
{
if (file_exists($compiled = __DIR__.'/compiled.php')) {
require $compiled;
}
@@ -69,7 +68,6 @@ Illuminate\Support\ClassLoader::register();
|
*/
if (is_dir($workbench = __DIR__.'/../workbench'))
{
if (is_dir($workbench = __DIR__.'/../workbench')) {
Illuminate\Workbench\Starter::start($workbench);
}

View File

@@ -1,6 +1,6 @@
<?php
return array(
return [
/*
|--------------------------------------------------------------------------
@@ -54,4 +54,4 @@ return array(
'storage' => __DIR__.'/../app/storage',
);
];

Some files were not shown because too many files have changed in this diff Show More