mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-04-14 04:22:22 +02:00
Cachet is now a Laravel 5 app
This commit is contained in:
parent
7cfa158e68
commit
b4ac66d727
2
.bowerrc
2
.bowerrc
@ -1,4 +1,4 @@
|
||||
{
|
||||
"directory": "app/assets/bower_components",
|
||||
"directory": "bower_components",
|
||||
"interactive": false
|
||||
}
|
||||
|
18
.env.example
Normal file
18
.env.example
Normal file
@ -0,0 +1,18 @@
|
||||
APP_ENV=local
|
||||
APP_DEBUG=true
|
||||
APP_KEY=SomeRandomString
|
||||
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=cachet
|
||||
DB_USERNAME=user
|
||||
DB_PASSWORD=secret
|
||||
|
||||
CACHE_DRIVER=apc
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
MAIL_HOST=mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'APP_DEBUG' => getenv('APP_DEBUG') ?: false,
|
||||
'DB_DRIVER' => 'mysql',
|
||||
'DB_HOST' => 'localhost',
|
||||
'DB_DATABASE' => 'cachet',
|
||||
'DB_USERNAME' => 'homestead',
|
||||
'DB_PASSWORD' => 'secret',
|
||||
'CACHE_DRIVER' => 'apc',
|
||||
];
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -1,4 +1,6 @@
|
||||
* text=auto
|
||||
*.css linguist-vendored
|
||||
*.less linguist-vendored
|
||||
|
||||
/tests export-ignore
|
||||
/.gitattributes export-ignore
|
||||
|
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,16 +1,12 @@
|
||||
# Laravel
|
||||
bootstrap/compiled.php
|
||||
vendor
|
||||
|
||||
# Configuration
|
||||
.env.*.php
|
||||
.env.php
|
||||
.env
|
||||
config.codekit
|
||||
!.env.heroku.php
|
||||
!.env.example.php
|
||||
|
||||
# Assets
|
||||
app/assets/bower_components
|
||||
bower_components
|
||||
node_modules
|
||||
public/dist
|
||||
public/css
|
||||
|
6
app/Commands/Command.php
Normal file
6
app/Commands/Command.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php namespace CachetHQ\Cachet\Commands;
|
||||
|
||||
abstract class Command
|
||||
{
|
||||
//
|
||||
}
|
@ -24,7 +24,7 @@ class TimezoneLocaleComposer
|
||||
$locale = basename($lang);
|
||||
|
||||
return [$locale => $enabledLangs[$locale]];
|
||||
}, glob(app_path('lang').'/*'));
|
||||
}, glob(base_path('resources/lang').'/*'));
|
||||
|
||||
$langs = call_user_func_array('array_merge', $langs);
|
||||
|
31
app/Console/Kernel.php
Normal file
31
app/Console/Kernel.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Console;
|
||||
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
||||
|
||||
class Kernel extends ConsoleKernel
|
||||
{
|
||||
/**
|
||||
* The Artisan commands provided by your application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $commands = [
|
||||
'CachetHQ\Cachet\Console\Commands\FixPermissionsCommand',
|
||||
'CachetHQ\Cachet\Console\Commands\OneClickDeployCommand',
|
||||
];
|
||||
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
6
app/Events/Event.php
Normal file
6
app/Events/Event.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php namespace CachetHQ\Cachet\Events;
|
||||
|
||||
abstract class Event
|
||||
{
|
||||
//
|
||||
}
|
54
app/Exceptions/Handler.php
Normal file
54
app/Exceptions/Handler.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php namespace CachetHQ\Cachet\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
'Symfony\Component\HttpKernel\Exception\HttpException',
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
return parent::report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($request->is('api*')) {
|
||||
if ($e instanceof \CachetHQ\Cachet\Repositories\InvalidModelValidationException) {
|
||||
return Response::make(['status_code' => 400, 'message' => 'Bad Request'], 400);
|
||||
}
|
||||
|
||||
if ($e instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) {
|
||||
return Response::make(['status_code' => 404, 'error' => 'Resource not found'], 404);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
12
app/Http/Controllers/AbstractController.php
Normal file
12
app/Http/Controllers/AbstractController.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
|
||||
abstract class AbstractController extends BaseController
|
||||
{
|
||||
use DispatchesCommands, ValidatesRequests;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
@ -9,7 +9,7 @@ use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class DashAPIController extends Controller
|
||||
class ApiController extends Controller
|
||||
{
|
||||
/**
|
||||
* Updates a component with the entered info.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class DashComponentController extends Controller
|
||||
class ComponentController extends Controller
|
||||
{
|
||||
protected $subMenu = [];
|
||||
|
||||
@ -32,9 +32,10 @@ class DashComponentController extends Controller
|
||||
],
|
||||
];
|
||||
|
||||
View::share('subMenu', $this->subMenu);
|
||||
|
||||
View::share('subTitle', trans_choice('dashboard.components.components', 2));
|
||||
View::share([
|
||||
'subMenu' => $this->subMenu,
|
||||
'subTitle' => trans_choice('dashboard.components.components', 2),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,6 +254,12 @@ class DashComponentController extends Controller
|
||||
'event' => 'Deleted Component Group',
|
||||
]);
|
||||
|
||||
$group->components->map(function ($component) {
|
||||
$component->update([
|
||||
'group_id' => 0,
|
||||
]);
|
||||
});
|
||||
|
||||
$group->delete();
|
||||
|
||||
return Redirect::back();
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use Illuminate\Routing\Controller;
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class DashIncidentController extends Controller
|
||||
class IncidentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Stores the sub-sidebar tree list.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
@ -9,7 +9,7 @@ use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class DashMetricController extends Controller
|
||||
class MetricController extends Controller
|
||||
{
|
||||
/**
|
||||
* Shows the metrics view.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
@ -14,7 +14,7 @@ use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class DashScheduleController extends Controller
|
||||
class ScheduleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Stores the sub-sidebar tree list.
|
@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use CachetHQ\Cachet\Controllers\AbstractController;
|
||||
use Illuminate\Support\Facades\Lang;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class DashSettingsController extends Controller
|
||||
class SettingsController extends AbstractController
|
||||
{
|
||||
protected $subMenu = [];
|
||||
protected $subTitle = 'Settings';
|
||||
@ -88,9 +89,12 @@ class DashSettingsController extends Controller
|
||||
{
|
||||
$this->subMenu['security']['active'] = true;
|
||||
|
||||
$unsecureUsers = User::whereNull('google_2fa_secret')->orWhere('google_2fa_secret', '')->get();
|
||||
|
||||
return View::make('dashboard.settings.security')->with([
|
||||
'pageTitle' => 'Security - Dashboard',
|
||||
'subMenu' => $this->subMenu,
|
||||
'pageTitle' => 'Security - Dashboard',
|
||||
'subMenu' => $this->subMenu,
|
||||
'unsecureUsers' => $unsecureUsers,
|
||||
]);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@ -8,7 +8,7 @@ use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class DashTeamController extends Controller
|
||||
class TeamController extends Controller
|
||||
{
|
||||
/**
|
||||
* Shows the team members view.
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Admin;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@ -10,7 +10,7 @@ use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use PragmaRX\Google2FA\Vendor\Laravel\Facade as Google2FA;
|
||||
|
||||
class DashUserController extends Controller
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Shows the user view.
|
160
app/Http/Controllers/Api/AbstractApiController.php
Normal file
160
app/Http/Controllers/Api/AbstractApiController.php
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Http\Controllers\AbstractController as BaseController;
|
||||
use Illuminate\Contracts\Pagination\Paginator;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
abstract class AbstractApiController extends BaseController
|
||||
{
|
||||
/**
|
||||
* The HTTP response headers.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $headers = [];
|
||||
|
||||
/**
|
||||
* The HTTP response meta data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $meta = [];
|
||||
|
||||
/**
|
||||
* The HTTP response data.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
/**
|
||||
* The HTTP response status code.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $statusCode = 200;
|
||||
|
||||
/**
|
||||
* Set the response headers.
|
||||
*
|
||||
* @param array $headers
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setHeaders(array $headers)
|
||||
{
|
||||
$this->headers = $headers;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the response meta data.
|
||||
*
|
||||
* @param array $meta
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setMetaData(array $meta)
|
||||
{
|
||||
$this->meta = $meta;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the response meta data.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setData(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the response status code.
|
||||
*
|
||||
* @param int $statusCode
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
protected function setStatusCode($satusCode)
|
||||
{
|
||||
$this->satusCode = $satusCode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with a pagination response.
|
||||
*
|
||||
* @param \Illuminate\Pagination\Paginator $paginator
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function paginator(Paginator $paginator, Request $request)
|
||||
{
|
||||
foreach ($request->query as $key => $value) {
|
||||
if ($key != 'page') {
|
||||
$paginator->addQuery($key, $value);
|
||||
}
|
||||
}
|
||||
|
||||
$pagination = [
|
||||
'pagination' => [
|
||||
'total' => $paginator->total(),
|
||||
'count' => count($paginator->items()),
|
||||
'per_page' => $paginator->perPage(),
|
||||
'current_page' => $paginator->currentPage(),
|
||||
'total_pages' => $paginator->lastPage(),
|
||||
'links' => [
|
||||
'next_page' => $paginator->nextPageUrl(),
|
||||
'previous_page' => $paginator->previousPageUrl(),
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $this->setMetaData($pagination)->setData($paginator->items())->respond();
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond with a no content response.
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function noContent()
|
||||
{
|
||||
return $this->setStatusCode(204)->respond();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the response.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function respond()
|
||||
{
|
||||
if (! empty($this->meta)) {
|
||||
$response['meta'] = $this->meta;
|
||||
}
|
||||
|
||||
$response['data'] = $this->data;
|
||||
|
||||
if ($this->data instanceof Arrayable) {
|
||||
$response['data'] = $this->data->toArray();
|
||||
}
|
||||
|
||||
return Response::json($response, $this->statusCode, $this->headers);
|
||||
}
|
||||
}
|
@ -4,14 +4,11 @@ namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Models\Tag;
|
||||
use CachetHQ\Cachet\Repositories\Component\ComponentRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ComponentController extends Controller
|
||||
class ComponentController extends AbstractApiController
|
||||
{
|
||||
use ControllerTrait;
|
||||
|
||||
/**
|
||||
* The component repository instance.
|
||||
*
|
||||
@ -36,9 +33,11 @@ class ComponentController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getComponents()
|
||||
public function getComponents(Request $request)
|
||||
{
|
||||
return $this->component->all();
|
||||
$components = $this->component->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->paginator($components, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,6 +119,6 @@ class ComponentController extends Controller
|
||||
{
|
||||
$this->component->destroy($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
@ -3,15 +3,11 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
|
||||
use CachetHQ\Cachet\Transformers\IncidentTransformer;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class IncidentController extends Controller
|
||||
class IncidentController extends AbstractApiController
|
||||
{
|
||||
use ControllerTrait;
|
||||
|
||||
/**
|
||||
* The incident repository instance.
|
||||
*
|
||||
@ -36,11 +32,11 @@ class IncidentController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getIncidents()
|
||||
public function getIncidents(Request $request)
|
||||
{
|
||||
$incidents = $this->incident->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->response->paginator($incidents, new IncidentTransformer());
|
||||
return $this->paginator($incidents, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,6 +84,6 @@ class IncidentController extends Controller
|
||||
{
|
||||
$this->incident->destroy($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
@ -3,14 +3,11 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class MetricController extends Controller
|
||||
class MetricController extends AbstractApiController
|
||||
{
|
||||
use ControllerTrait;
|
||||
|
||||
/**
|
||||
* The metric repository instance.
|
||||
*
|
||||
@ -35,9 +32,11 @@ class MetricController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function getMetrics()
|
||||
public function getMetrics(Request $request)
|
||||
{
|
||||
return $this->metric->all();
|
||||
$metrics = $this->metric->paginate(Binput::get('per_page', 20));
|
||||
|
||||
return $this->paginator($metrics, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,6 +96,6 @@ class MetricController extends Controller
|
||||
{
|
||||
$this->metric->destroy($id);
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
@ -3,14 +3,10 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class MetricPointController extends Controller
|
||||
class MetricPointController extends AbstractApiController
|
||||
{
|
||||
use ControllerTrait;
|
||||
|
||||
/**
|
||||
* The metric point repository instance.
|
||||
*
|
||||
@ -82,6 +78,6 @@ class MetricPointController extends Controller
|
||||
{
|
||||
$this->metricPoint->destroy($pointId);
|
||||
|
||||
return $this->response->noContent();
|
||||
return $this->noContent();
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ class AtomController extends Controller
|
||||
|
||||
$feed->setDateFormat('datetime');
|
||||
|
||||
Incident::get()->map(function ($incident) use ($feed) {
|
||||
Incident::all()->map(function ($incident) use ($feed) {
|
||||
if ($incident->component) {
|
||||
$componentName = $incident->component->name;
|
||||
} else {
|
38
app/Http/Controllers/Auth/AuthController.php
Normal file
38
app/Http/Controllers/Auth/AuthController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php namespace CachetHQ\Cachet\Http\Controllers\Auth;
|
||||
|
||||
use CachetHQ\Cachet\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Registration & Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users, as well as the
|
||||
| authentication of existing users. By default, this controller uses
|
||||
| a simple trait to add these behaviors. Why don't you explore it?
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\Registrar $registrar
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, Registrar $registrar)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->registrar = $registrar;
|
||||
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
}
|
38
app/Http/Controllers/Auth/PasswordController.php
Normal file
38
app/Http/Controllers/Auth/PasswordController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php namespace CachetHQ\Cachet\Http\Controllers\Auth;
|
||||
|
||||
use CachetHQ\Cachet\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
@ -4,17 +4,17 @@ namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use Carbon\Carbon;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use GrahamCampbell\Markdown\Facades\Markdown;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Jenssegers\Date\Date;
|
||||
|
||||
class HomeController extends Controller
|
||||
class HomeController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Returns the rendered Blade templates.
|
||||
@ -23,20 +23,12 @@ class HomeController extends Controller
|
||||
*/
|
||||
public function showIndex()
|
||||
{
|
||||
segment_track('Status Page', [
|
||||
'event' => 'Landed',
|
||||
]);
|
||||
|
||||
$components = Component::orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
$allIncidents = [];
|
||||
|
||||
$incidentDays = Setting::get('app_incident_days') ?: 7;
|
||||
|
||||
$today = Carbon::now();
|
||||
$startDate = Carbon::now();
|
||||
|
||||
$dateFormat = Setting::get('date_format') ?: 'jS F Y';
|
||||
segment_track('Status Page', [
|
||||
'event' => 'Landed',
|
||||
]);
|
||||
|
||||
// Check if we have another starting date
|
||||
if (Binput::has('start_date')) {
|
||||
@ -73,9 +65,12 @@ class HomeController extends Controller
|
||||
$metrics = Metric::where('display_chart', 1)->get();
|
||||
}
|
||||
|
||||
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
|
||||
$allIncidents = [];
|
||||
$daysToShow = Setting::get('app_incident_days') ?: 7;
|
||||
$incidentDays = range(0, $daysToShow);
|
||||
$dateFormat = Setting::get('date_format') ?: 'jS F Y';
|
||||
|
||||
foreach (range(0, $incidentDays) as $i) {
|
||||
foreach ($incidentDays as $i) {
|
||||
$date = $startDate->copy()->subDays($i);
|
||||
|
||||
$incidents = Incident::notScheduled()->whereBetween('created_at', [
|
||||
@ -89,14 +84,23 @@ class HomeController extends Controller
|
||||
];
|
||||
}
|
||||
|
||||
// Scheduled maintenance code.
|
||||
$scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
|
||||
|
||||
// Component & Component Group lists.
|
||||
$usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
|
||||
$componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->get();
|
||||
$ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
|
||||
|
||||
return View::make('index', [
|
||||
'components' => $components,
|
||||
'componentGroups' => $componentGroups,
|
||||
'ungroupedComponents' => $ungroupedComponents,
|
||||
'displayMetrics' => $displayMetrics,
|
||||
'metrics' => $metrics,
|
||||
'allIncidents' => $allIncidents,
|
||||
'scheduledMaintenance' => $scheduledMaintenance,
|
||||
'pageTitle' => Setting::get('app_name'),
|
||||
'aboutApp' => Markdown::render(Setting::get('app_about')),
|
||||
'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')),
|
||||
'canPageForward' => (bool) $today->gt($startDate),
|
||||
'previousDate' => $startDate->copy()->subWeek()->subDay()->toDateString(),
|
||||
'nextDate' => $startDate->copy()->addWeek()->addDay()->toDateString(),
|
46
app/Http/Controllers/RssController.php
Normal file
46
app/Http/Controllers/RssController.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
use Roumen\Feed\Facades\Feed;
|
||||
|
||||
class RssController extends Controller
|
||||
{
|
||||
/**
|
||||
* Generates an RSS feed of all incidents.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function feedAction()
|
||||
{
|
||||
$feed = Feed::make();
|
||||
$feed->title = Setting::get('app_name');
|
||||
$feed->description = trans('cachet.feed');
|
||||
$feed->link = Setting::get('app_domain');
|
||||
|
||||
$feed->setDateFormat('datetime');
|
||||
|
||||
Incident::all()->map(function ($incident) use ($feed) {
|
||||
if ($incident->component) {
|
||||
$componentName = $incident->component->name;
|
||||
} else {
|
||||
$componentName = null;
|
||||
}
|
||||
|
||||
$feed->add(
|
||||
$incident->name,
|
||||
Setting::get('app_name'),
|
||||
Setting::get('app_domain'),
|
||||
$incident->created_at,
|
||||
($componentName === null ? $incident->humanStatus : $componentName.' '.$incident->humanStatus),
|
||||
$incident->message
|
||||
);
|
||||
});
|
||||
|
||||
return $feed->render('rss');
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ namespace CachetHQ\Cachet\Http\Controllers;
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
@ -14,7 +13,7 @@ use Illuminate\Support\Facades\Session;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
||||
class SetupController extends Controller
|
||||
class SetupController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Create a new setup controller instance.
|
||||
@ -60,9 +59,20 @@ class SetupController extends Controller
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 1',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
return Response::json(['status' => 1]);
|
||||
} else {
|
||||
// No good, let's try that again.
|
||||
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 1',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
}
|
||||
@ -115,12 +125,22 @@ class SetupController extends Controller
|
||||
|
||||
Session::flash('setup.done', true);
|
||||
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 2',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['status' => 1]);
|
||||
}
|
||||
|
||||
return Redirect::to('dashboard');
|
||||
} else {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 2',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
// No good, let's try that again.
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
40
app/Http/Kernel.php
Normal file
40
app/Http/Kernel.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'CachetHQ\Cachet\Http\Middleware\Authenticate',
|
||||
'auth.api' => 'CachetHQ\Cachet\Http\Middleware\ApiAuthenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'CachetHQ\Cachet\Http\Middleware\RedirectIfAuthenticated',
|
||||
'csrf' => 'CachetHQ\Cachet\Http\Middleware\VerifyCsrfToken',
|
||||
'admin' => 'CachetHQ\Cachet\Http\Middleware\Admin',
|
||||
'login.throttling' => 'CachetHQ\Cachet\Http\Middleware\LoginThrottling',
|
||||
'app.isSetup' => 'CachetHQ\Cachet\Http\Middleware\AppIsSetup',
|
||||
'app.hasSetting' => 'CachetHQ\Cachet\Http\Middleware\HasSetting',
|
||||
'allowedDomains' => 'CachetHQ\Cachet\Http\Middleware\AllowedDomains',
|
||||
'cors' => 'CachetHQ\Cachet\Http\Middleware\Cors',
|
||||
];
|
||||
}
|
50
app/Http/Middleware/Admin.php
Normal file
50
app/Http/Middleware/Admin.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Support\Facades\Response;
|
||||
|
||||
class Admin
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the cors middleware.
|
||||
*
|
||||
* We're verifying that the current user is logged in to Cachet and is an admin level.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!$this->auth->check() || ($this->auth->check() && !$this->auth->user()->isAdmin)) {
|
||||
return Response::view('errors.401', [
|
||||
'pageTitle' => trans('errors.unauthorized.title'),
|
||||
], 401);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -1,25 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\After;
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Closure;
|
||||
|
||||
class AllowedDomainsFilter
|
||||
class AllowedDomains
|
||||
{
|
||||
/**
|
||||
* Run the allowed domains filter.
|
||||
* Run the allowed domains middleware.
|
||||
*
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Symfony\Component\HttpFoundation\Response $response
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter(Route $route, Request $request, Response $response)
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
// Always allow our own domain.
|
||||
$ourDomain = Setting::get('app_domain');
|
||||
$response->headers->set('Access-Control-Allow-Origin', $ourDomain);
|
39
app/Http/Middleware/ApiAuthenticate.php
Normal file
39
app/Http/Middleware/ApiAuthenticate.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
|
||||
class ApiAuthenticate
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($apiToken = $request->header('X-Cachet-Token')) {
|
||||
try {
|
||||
User::findByApiToken($apiToken);
|
||||
} catch (ModelNotFoundException $e) {
|
||||
return response()->json([
|
||||
'message' => 'The API token you provided was not correct.',
|
||||
'status_code' => 401,
|
||||
], 401);
|
||||
}
|
||||
} else {
|
||||
return response()->json([
|
||||
'message' => 'You are not authorized to view this content.',
|
||||
'status_code' => 401,
|
||||
], 401);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Before;
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class IsSetupFilter
|
||||
class AppIsSetup
|
||||
{
|
||||
/**
|
||||
* Run the is setup filter.
|
||||
@ -17,19 +16,21 @@ class IsSetupFilter
|
||||
* sending the user to the dashboard so they can use Cachet.
|
||||
*
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return \Illuminate\Http\Response|null
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter(Route $route, Request $request)
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
try {
|
||||
$setting = Setting::where('name', 'app_name')->first();
|
||||
if ($setting && $setting->value) {
|
||||
return Redirect::to('/dashboard');
|
||||
return Redirect::route('dashboard');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
49
app/Http/Middleware/Authenticate.php
Normal file
49
app/Http/Middleware/Authenticate.php
Normal file
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
25
app/Http/Middleware/Cors.php
Normal file
25
app/Http/Middleware/Cors.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
|
||||
class Cors
|
||||
{
|
||||
/**
|
||||
* Run the cors middleware.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
$response->headers->set('Access-Control-Allow-Origin', '*');
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
53
app/Http/Middleware/HasSetting.php
Normal file
53
app/Http/Middleware/HasSetting.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Models\Setting;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class HasSetting
|
||||
{
|
||||
/**
|
||||
* Run the has setting middleware.
|
||||
*
|
||||
* We're verifying that the given setting exists in our database. If it
|
||||
* doesn't, then we're sending the user to the setup page so that they can
|
||||
* complete the installation of Cachet on their server.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$settingName = $this->getSettingName($request);
|
||||
|
||||
try {
|
||||
$setting = Setting::where('name', $settingName)->first();
|
||||
if (!$setting || !$setting->value) {
|
||||
return Redirect::to('setup');
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return Redirect::to('setup');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the setting from the request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function getSettingName($request)
|
||||
{
|
||||
$actions = $request->route()->getAction();
|
||||
|
||||
return $actions['setting'];
|
||||
}
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Before;
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use GrahamCampbell\Throttle\Facades\Throttle;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Facades\Redirect;
|
||||
|
||||
class LoginThrottlingFilter
|
||||
class LoginThrottling
|
||||
{
|
||||
/**
|
||||
* Run the login throttling filter.
|
||||
* Run the login throttling middleware.
|
||||
*
|
||||
* We're verifying that the user is not attempting to brute force Cachet's
|
||||
* login system. If the user has reached the rate limit, then we're sending
|
||||
@ -20,15 +19,17 @@ class LoginThrottlingFilter
|
||||
* Another part of Cachet will increment the hit count for the given route
|
||||
* only if validation passes, and the user did not successfully login.
|
||||
*
|
||||
* @param \Illuminate\Routing\Route $route
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return \Illuminate\Http\Response|null
|
||||
* @return mixed
|
||||
*/
|
||||
public function filter(Route $route, Request $request)
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if (!Throttle::check($request, 10, 10)) {
|
||||
return Redirect::back()->with('error', 'You have made too many login requests.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
46
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
46
app/Http/Middleware/RedirectIfAuthenticated.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check()) {
|
||||
return new RedirectResponse(url('/home'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
22
app/Http/Middleware/VerifyCsrfToken.php
Normal file
22
app/Http/Middleware/VerifyCsrfToken.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
}
|
8
app/Http/Requests/Request.php
Normal file
8
app/Http/Requests/Request.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php namespace CachetHQ\Cachet\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest
|
||||
{
|
||||
//
|
||||
}
|
200
app/Http/Routes/AdminRoutes.php
Normal file
200
app/Http/Routes/AdminRoutes.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Routes;
|
||||
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
class AdminRoutes
|
||||
{
|
||||
/**
|
||||
* Define the dashboard routes.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Routing\Registrar $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
$router->group([
|
||||
'middleware' => 'auth',
|
||||
'prefix' => 'dashboard',
|
||||
'namespace' => 'Admin',
|
||||
], function ($router) {
|
||||
// Dashboard
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard',
|
||||
'uses' => 'DashboardController@showDashboard',
|
||||
]);
|
||||
|
||||
// Components
|
||||
$router->group(['prefix' => 'components'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.components',
|
||||
'uses' => 'ComponentController@showComponents',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.components.add',
|
||||
'uses' => 'ComponentController@showAddComponent',
|
||||
]);
|
||||
$router->post('add', 'ComponentController@createComponentAction');
|
||||
$router->get('groups', [
|
||||
'as' => 'dashboard.components.groups',
|
||||
'uses' => 'ComponentController@showComponentGroups',
|
||||
]);
|
||||
$router->get('groups/add', [
|
||||
'as' => 'dashboard.components.groups.add',
|
||||
'uses' => 'ComponentController@showAddComponentGroup',
|
||||
]);
|
||||
$router->get('groups/edit/{component_group}', [
|
||||
'as' => 'dashboard.components.groups.edit',
|
||||
'uses' => 'ComponentController@showEditComponentGroup',
|
||||
]);
|
||||
$router->post('groups/edit/{component_group}', 'ComponentController@updateComponentGroupAction');
|
||||
|
||||
$router->delete('groups/{component_group}/delete', 'ComponentController@deleteComponentGroupAction');
|
||||
$router->post('groups/add', 'ComponentController@postAddComponentGroup');
|
||||
$router->delete('{component}/delete', 'ComponentController@deleteComponentAction');
|
||||
$router->get('{component}/edit', 'ComponentController@showEditComponent');
|
||||
$router->post('{component}/edit', 'ComponentController@updateComponentAction');
|
||||
});
|
||||
|
||||
// Incidents
|
||||
$router->group(['prefix' => 'incidents'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.incidents',
|
||||
'uses' => 'IncidentController@showIncidents',
|
||||
]);
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.incidents.add',
|
||||
'uses' => 'IncidentController@showAddIncident',
|
||||
]);
|
||||
$router->post('add', 'IncidentController@createIncidentAction');
|
||||
$router->delete('{incident}/delete', 'IncidentController@deleteIncidentAction');
|
||||
$router->get('{incident}/edit', 'IncidentController@showEditIncidentAction');
|
||||
$router->post('{incident}/edit', 'IncidentController@editIncidentAction');
|
||||
});
|
||||
|
||||
// Scheduled Maintenance
|
||||
$router->group(['prefix' => 'schedule'], function ($router) {
|
||||
$router->get('/', ['as' => 'dashboard.schedule', 'uses' => 'ScheduleController@showIndex']);
|
||||
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.schedule.add',
|
||||
'uses' => 'ScheduleController@showAddSchedule',
|
||||
]);
|
||||
$router->post('add', 'ScheduleController@addScheduleAction');
|
||||
|
||||
$router->get('{incident}/edit', [
|
||||
'as' => 'dashboard.schedule.edit',
|
||||
'uses' => 'ScheduleController@showEditSchedule',
|
||||
]);
|
||||
$router->post('{incident}/edit', 'ScheduleController@editScheduleAction');
|
||||
|
||||
$router->delete('{incident}/delete', [
|
||||
'as' => 'dashboard.schedule.delete',
|
||||
'uses' => 'ScheduleController@deleteScheduleAction',
|
||||
]);
|
||||
});
|
||||
|
||||
// Incident Templates
|
||||
$router->group(['prefix' => 'templates'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.templates',
|
||||
'uses' => 'IncidentController@showTemplates',
|
||||
]);
|
||||
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.templates.add',
|
||||
'uses' => 'IncidentController@showAddIncidentTemplate',
|
||||
]);
|
||||
$router->post('add', 'IncidentController@createIncidentTemplateAction');
|
||||
|
||||
$router->get('{incident_template}/edit', 'IncidentController@showEditTemplateAction');
|
||||
$router->post('{incident_template}/edit', 'IncidentController@editTemplateAction');
|
||||
$router->delete('{incident_template}/delete', 'IncidentController@deleteTemplateAction');
|
||||
});
|
||||
|
||||
// Metrics
|
||||
$router->group(['prefix' => 'metrics'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.metrics',
|
||||
'uses' => 'MetricController@showMetrics',
|
||||
]);
|
||||
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.metrics.add',
|
||||
'uses' => 'MetricController@showAddMetric',
|
||||
]);
|
||||
$router->post('add', 'MetricController@createMetricAction');
|
||||
$router->delete('{metric}/delete', 'MetricController@deleteMetricAction');
|
||||
$router->get('{metric}/edit', 'MetricController@showEditMetricAction');
|
||||
$router->post('{metric}/edit', 'MetricController@editMetricAction');
|
||||
});
|
||||
|
||||
// Notifications
|
||||
$router->group(['prefix' => 'notifications'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.notifications',
|
||||
'uses' => 'DashboardController@showNotifications',
|
||||
]);
|
||||
});
|
||||
|
||||
// Team Members
|
||||
$router->group(['prefix' => 'team'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.team',
|
||||
'uses' => 'TeamController@showTeamView',
|
||||
]);
|
||||
|
||||
$router->group(['middleware' => 'admin'], function ($router) {
|
||||
$router->get('add', [
|
||||
'as' => 'dashboard.team.add',
|
||||
'uses' => 'TeamController@showAddTeamMemberView',
|
||||
]);
|
||||
$router->get('{user}', 'TeamController@showTeamMemberView');
|
||||
$router->post('add', 'TeamController@postAddUser');
|
||||
$router->post('{user}', 'TeamController@postUpdateUser');
|
||||
});
|
||||
});
|
||||
|
||||
// Settings
|
||||
$router->group(['prefix' => 'settings'], function ($router) {
|
||||
$router->get('setup', [
|
||||
'as' => 'dashboard.settings.setup',
|
||||
'uses' => 'SettingsController@showSetupView',
|
||||
]);
|
||||
$router->get('security', [
|
||||
'as' => 'dashboard.settings.security',
|
||||
'uses' => 'SettingsController@showSecurityView',
|
||||
]);
|
||||
$router->get('theme', [
|
||||
'as' => 'dashboard.settings.theme',
|
||||
'uses' => 'SettingsController@showThemeView',
|
||||
]);
|
||||
$router->get('stylesheet', [
|
||||
'as' => 'dashboard.settings.stylesheet',
|
||||
'uses' => 'SettingsController@showStylesheetView',
|
||||
]);
|
||||
$router->post('/', 'SettingsController@postSettings');
|
||||
});
|
||||
|
||||
// User Settings
|
||||
$router->group(['prefix' => 'user'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'dashboard.user',
|
||||
'uses' => 'UserController@showUser',
|
||||
]);
|
||||
$router->post('/', 'UserController@postUser');
|
||||
$router->get('{user}/api/regen', 'UserController@regenerateApiKey');
|
||||
});
|
||||
|
||||
// Internal API.
|
||||
// This should only be used for making requests within the dashboard.
|
||||
$router->group(['prefix' => 'api'], function ($router) {
|
||||
$router->get('incidents/templates', 'APIController@getIncidentTemplate');
|
||||
$router->post('components/order', 'APIController@postUpdateComponentOrder');
|
||||
$router->post('components/{component}', 'APIController@postUpdateComponent');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
55
app/Http/Routes/ApiRoutes.php
Normal file
55
app/Http/Routes/ApiRoutes.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Routes;
|
||||
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
class ApiRoutes
|
||||
{
|
||||
/**
|
||||
* Define the api routes.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Routing\Registrar $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
$router->group([
|
||||
'middleware' => 'allowedDomains',
|
||||
'namespace' => 'Api',
|
||||
'prefix' => 'api/v1',
|
||||
], function ($router) {
|
||||
// Components
|
||||
$router->get('components', 'ComponentController@getComponents');
|
||||
$router->get('components/{id}', 'ComponentController@getComponent');
|
||||
|
||||
// Incidents
|
||||
$router->get('incidents', 'IncidentController@getIncidents');
|
||||
$router->get('incidents/{id}', 'IncidentController@getIncident');
|
||||
|
||||
// Metrics
|
||||
$router->get('metrics', 'MetricController@getMetrics');
|
||||
$router->get('metrics/{id}', 'MetricController@getMetric');
|
||||
$router->get('metrics/{id}/points', 'MetricController@getMetricPoints');
|
||||
|
||||
// Api protected
|
||||
$router->group(['middleware' => 'auth.api'], function ($router) {
|
||||
$router->post('components', 'ComponentController@postComponents');
|
||||
$router->post('incidents', 'IncidentController@postIncidents');
|
||||
$router->post('metrics', 'MetricController@postMetrics');
|
||||
$router->post('metrics/{id}/points', 'MetricPointController@postMetricPoints');
|
||||
|
||||
$router->put('components/{id}', 'ComponentController@putComponent');
|
||||
$router->put('incidents/{id}', 'IncidentController@putIncident');
|
||||
$router->put('metrics/{id}', 'MetricController@putMetric');
|
||||
$router->put('metrics/{id}/points/{metric_id}', 'MetricPointController@putMetricPoint');
|
||||
|
||||
$router->delete('components/{id}', 'ComponentController@deleteComponent');
|
||||
$router->delete('incidents/{id}', 'IncidentController@deleteIncident');
|
||||
$router->delete('metrics/{id}', 'MetricController@deleteMetric');
|
||||
$router->delete('metrics/{id}/points/{metric_id}', 'MetricPointController@deleteMetricPoint');
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
50
app/Http/Routes/AuthRoutes.php
Normal file
50
app/Http/Routes/AuthRoutes.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Routes;
|
||||
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
class AuthRoutes
|
||||
{
|
||||
/**
|
||||
* Define the auth routes.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Routing\Registrar $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
$router->group(['prefix' => 'auth'], function ($router) {
|
||||
$router->group(['middleware' => 'app.hasSetting', 'setting' => 'app_name'], function ($router) {
|
||||
// Login routes
|
||||
$router->get('login', [
|
||||
'middleware' => 'guest',
|
||||
'as' => 'login',
|
||||
'uses' => 'AuthController@showLogin',
|
||||
]);
|
||||
|
||||
$router->post('login', [
|
||||
'middleware' => ['guest', 'csrf', 'login.throttling'],
|
||||
'as' => 'logout',
|
||||
'uses' => 'AuthController@postLogin',
|
||||
]);
|
||||
|
||||
// Two factor authorization
|
||||
$router->get('2fa', [
|
||||
'as' => 'two-factor',
|
||||
'uses' => 'AuthController@showTwoFactorAuth',
|
||||
]);
|
||||
|
||||
$router->post('2fa', 'AuthController@postTwoFactor');
|
||||
});
|
||||
|
||||
$router->group(['middleware' => 'auth'], function ($router) {
|
||||
$router->get('logout', [
|
||||
'as' => 'logout',
|
||||
'uses' => 'AuthController@logoutAction',
|
||||
]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
22
app/Http/Routes/SetupRoutes.php
Normal file
22
app/Http/Routes/SetupRoutes.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Routes;
|
||||
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
class SetupRoutes
|
||||
{
|
||||
/**
|
||||
* Define the setup routes.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Routing\Registrar $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
$router->group(['middleware' => 'app.isSetup'], function ($router) {
|
||||
$router->controller('setup', 'SetupController');
|
||||
});
|
||||
}
|
||||
}
|
28
app/Http/Routes/StatusPageRoutes.php
Normal file
28
app/Http/Routes/StatusPageRoutes.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Routes;
|
||||
|
||||
use Illuminate\Contracts\Routing\Registrar;
|
||||
|
||||
class StatusPageRoutes
|
||||
{
|
||||
/**
|
||||
* Define the status page routes.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Routing\Registrar $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Registrar $router)
|
||||
{
|
||||
// Prevent access until the app is setup.
|
||||
$router->group(['middleware' => 'app.hasSetting', 'setting' => 'app_name'], function ($router) {
|
||||
$router->get('/', [
|
||||
'as' => 'status-page',
|
||||
'uses' => 'HomeController@showIndex',
|
||||
]);
|
||||
$router->get('/atom', 'AtomController@feedAction');
|
||||
$router->get('/rss', 'RssController@feedAction');
|
||||
});
|
||||
}
|
||||
}
|
121
app/Http/helpers.php
Normal file
121
app/Http/helpers.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Segment\Facades\Segment;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
|
||||
if (!function_exists('set_active')) {
|
||||
|
||||
/**
|
||||
* Set active class if request is in path.
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $classes
|
||||
* @param string $active
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function set_active($path, array $classes = [], $active = 'active')
|
||||
{
|
||||
if (Request::is($path)) {
|
||||
$classes[] = $active;
|
||||
}
|
||||
|
||||
$class = implode(' ', $classes);
|
||||
|
||||
return empty($classes) ? '' : "class=\"{$class}\"";
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_identify')) {
|
||||
/**
|
||||
* Identifies the user for Segment.com.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_identify()
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::identify([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_track')) {
|
||||
/**
|
||||
* Tracks events in Segment.com.
|
||||
*
|
||||
* @param string $event
|
||||
* @param array $properties
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_track($event, array $properties)
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::track([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'event' => $event,
|
||||
'properties' => $properties,
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_page')) {
|
||||
/**
|
||||
* Tracks pages in Segment.com.
|
||||
*
|
||||
* @param string $page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_page($page)
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::page([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'page' => $page,
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -2,11 +2,9 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use CachetHQ\Cachet\Transformers\ComponentTransformer;
|
||||
use Dingo\Api\Transformer\TransformableInterface;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
@ -22,30 +20,20 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
*/
|
||||
class Component extends Model implements TransformableInterface
|
||||
class Component extends Model
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rulesets = [
|
||||
[
|
||||
'creating' => [
|
||||
'user_id' => 'integer|required',
|
||||
'name' => 'required',
|
||||
'status' => 'integer|required',
|
||||
'link' => 'url',
|
||||
],
|
||||
],
|
||||
[
|
||||
'updating' => [
|
||||
'status' => 'integer',
|
||||
'link' => 'url',
|
||||
],
|
||||
],
|
||||
protected $rules = [
|
||||
'user_id' => 'integer|required',
|
||||
'name' => 'required',
|
||||
'status' => 'integer|required',
|
||||
'link' => 'url',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -76,6 +64,13 @@ class Component extends Model implements TransformableInterface
|
||||
'link' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* Components can belong to a group.
|
||||
*
|
||||
@ -155,14 +150,4 @@ class Component extends Model implements TransformableInterface
|
||||
|
||||
return implode(', ', $tags->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transformer instance.
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Transformers\ComponentTransformer
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
return new ComponentTransformer();
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
*/
|
||||
class ComponentGroup extends Model
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
@ -33,6 +33,13 @@ class ComponentGroup extends Model
|
||||
*/
|
||||
protected $fillable = ['name'];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = ['deleted_at'];
|
||||
|
||||
/**
|
||||
* A group can have many components.
|
||||
*
|
||||
@ -40,6 +47,6 @@ class ComponentGroup extends Model
|
||||
*/
|
||||
public function components()
|
||||
{
|
||||
return $this->hasMany('CachetHQ\Cachet\Models\Component', 'id', 'group_id');
|
||||
return $this->hasMany('CachetHQ\Cachet\Models\Component', 'group_id', 'id');
|
||||
}
|
||||
}
|
@ -2,12 +2,10 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use CachetHQ\Cachet\Transformers\IncidentTransformer;
|
||||
use Carbon\Carbon;
|
||||
use Dingo\Api\Transformer\TransformableInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use McCool\LaravelAutoPresenter\PresenterInterface;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
@ -22,9 +20,9 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
* @property \Carbon\Carbon $deleted_at
|
||||
*/
|
||||
class Incident extends Model implements TransformableInterface, PresenterInterface
|
||||
class Incident extends Model implements HasPresenter
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
||||
@ -51,7 +49,7 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $appends = ['humanStatus'];
|
||||
protected $appends = ['human_status'];
|
||||
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
@ -86,16 +84,6 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get presenter class.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPresenter()
|
||||
{
|
||||
return 'CachetHQ\Cachet\Presenters\IncidentPresenter';
|
||||
}
|
||||
|
||||
/**
|
||||
* An incident belongs to a component.
|
||||
*
|
||||
@ -129,12 +117,12 @@ class Incident extends Model implements TransformableInterface, PresenterInterfa
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transformer instance.
|
||||
* Get the presenter class.
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Transformers\IncidentTransformer
|
||||
* @return string
|
||||
*/
|
||||
public function getTransformer()
|
||||
public function getPresenterClass()
|
||||
{
|
||||
return new IncidentTransformer();
|
||||
return 'CachetHQ\Cachet\Presenters\IncidentPresenter';
|
||||
}
|
||||
}
|
@ -2,10 +2,8 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use CachetHQ\Cachet\Transformers\MetricTransformer;
|
||||
use DateInterval;
|
||||
use DateTime;
|
||||
use Dingo\Api\Transformer\TransformableInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -20,7 +18,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
*/
|
||||
class Metric extends Model implements TransformableInterface
|
||||
class Metric extends Model
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
@ -121,14 +119,4 @@ class Metric extends Model implements TransformableInterface
|
||||
{
|
||||
return $this->display_chart === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the transformer instance.
|
||||
*
|
||||
* @return \CachetHQ\Cachet\Transformers\MetricTransformer
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
return new MetricTransformer();
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ use Watson\Validating\ValidatingTrait;
|
||||
*/
|
||||
class Subscriber extends Model
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
use SoftDeletes, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
@ -2,10 +2,10 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use Illuminate\Auth\Reminders\RemindableInterface;
|
||||
use Illuminate\Auth\Reminders\RemindableTrait;
|
||||
use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserTrait;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@ -24,9 +24,9 @@ use Watson\Validating\ValidatingTrait;
|
||||
* @property \Carbon\Carbon $created_at
|
||||
* @property \Carbon\Carbon $updated_at
|
||||
*/
|
||||
class User extends Model implements UserInterface, RemindableInterface
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract
|
||||
{
|
||||
use RemindableTrait, UserTrait, ValidatingTrait;
|
||||
use Authenticatable, CanResetPassword, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The validation rules.
|
@ -20,11 +20,14 @@ class IncidentPresenter extends BasePresenter
|
||||
/**
|
||||
* Create a incident presenter instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
* @param object $resource
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Incident $incident)
|
||||
public function __construct($resource)
|
||||
{
|
||||
$this->resource = $incident;
|
||||
parent::__construct($resource);
|
||||
|
||||
$this->tz = Setting::get('app_timezone');
|
||||
}
|
||||
|
||||
@ -35,7 +38,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function formattedMessage()
|
||||
{
|
||||
return Markdown::render($this->resource->message);
|
||||
return Markdown::convertToHtml($this->wrappedObject->message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,7 +48,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function created_at_diff()
|
||||
{
|
||||
return (new Date($this->resource->created_at))
|
||||
return (new Date($this->wrappedObject->created_at))
|
||||
->setTimezone($this->tz)
|
||||
->diffForHumans();
|
||||
}
|
||||
@ -57,7 +60,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function created_at_formatted()
|
||||
{
|
||||
return ucfirst((new Date($this->resource->created_at))
|
||||
return ucfirst((new Date($this->wrappedObject->created_at))
|
||||
->setTimezone($this->tz)
|
||||
->format('l jS F Y H:i:s'));
|
||||
}
|
||||
@ -69,7 +72,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function created_at_iso()
|
||||
{
|
||||
return $this->resource->created_at->setTimezone($this->tz)->toISO8601String();
|
||||
return $this->wrappedObject->created_at->setTimezone($this->tz)->toISO8601String();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +82,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function scheduled_at_diff()
|
||||
{
|
||||
return (new Date($this->resource->scheduled_at))
|
||||
return (new Date($this->wrappedObject->scheduled_at))
|
||||
->setTimezone($this->tz)
|
||||
->diffForHumans();
|
||||
}
|
||||
@ -91,7 +94,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function scheduled_at_formatted()
|
||||
{
|
||||
return ucfirst((new Date($this->resource->scheduled_at))
|
||||
return ucfirst((new Date($this->wrappedObject->scheduled_at))
|
||||
->setTimezone($this->tz)
|
||||
->format('l jS F Y H:i:s'));
|
||||
}
|
||||
@ -103,7 +106,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function scheduled_at_iso()
|
||||
{
|
||||
return $this->resource->scheduled_at->setTimezone($this->tz)->toISO8601String();
|
||||
return $this->wrappedObject->scheduled_at->setTimezone($this->tz)->toISO8601String();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,7 +116,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function scheduled_at_datetimepicker()
|
||||
{
|
||||
return $this->resource->scheduled_at->setTimezone($this->tz)->format('d/m/Y H:i');
|
||||
return $this->wrappedObject->scheduled_at->setTimezone($this->tz)->format('d/m/Y H:i');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,7 +126,7 @@ class IncidentPresenter extends BasePresenter
|
||||
*/
|
||||
public function icon()
|
||||
{
|
||||
switch ($this->resource->status) {
|
||||
switch ($this->wrappedObject->status) {
|
||||
case 0: // Scheduled
|
||||
return 'icon ion-android-calendar';
|
||||
case 1: // Investigating
|
35
app/Providers/AppServiceProvider.php
Normal file
35
app/Providers/AppServiceProvider.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* This service provider is a great spot to register your various container
|
||||
* bindings with the application. As you can see, we are registering our
|
||||
* "Registrar" implementation here. You can add your own bindings too!
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(
|
||||
'Illuminate\Contracts\Auth\Registrar',
|
||||
'CachetHQ\Cachet\Services\Registrar'
|
||||
);
|
||||
}
|
||||
}
|
33
app/Providers/BusServiceProvider.php
Normal file
33
app/Providers/BusServiceProvider.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use Illuminate\Bus\Dispatcher;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BusServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @param \Illuminate\Bus\Dispatcher $dispatcher
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
$dispatcher->mapUsing(function ($command) {
|
||||
return Dispatcher::simpleMapping(
|
||||
$command, 'CachetHQ\Cachet\Commands', 'CachetHQ\Cachet\Handlers\Commands'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
22
app/Providers/ConfigServiceProvider.php
Normal file
22
app/Providers/ConfigServiceProvider.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class ConfigServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Overwrite any vendor / package configuration.
|
||||
*
|
||||
* This service provider is intended to provide a convenient location for you
|
||||
* to overwrite any "vendor" or package configuration that you may want to
|
||||
* modify before the application handles the incoming request / command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
config([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
@ -15,8 +15,7 @@ class ConsoleServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->commands('CachetHQ\Cachet\Console\Commands\FixPermissionsCommand');
|
||||
$this->commands('CachetHQ\Cachet\Console\Commands\OneClickDeployCommand');
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
@ -27,8 +26,8 @@ class ConsoleServiceProvider extends ServiceProvider
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('CachetHQ\Cachet\Console\Commands\FixPermissionsCommand', function ($app) {
|
||||
$storageDirectory = $app['path.storage'];
|
||||
$databaseDirectory = $app['path'].'/database';
|
||||
$storageDirectory = storage_path();
|
||||
$databaseDirectory = base_path('database');
|
||||
$databasePath = $app->config->get('database.connections.sqlite.database');
|
||||
$databaseDefault = $app->config->get('database.default');
|
||||
|
32
app/Providers/EventServiceProvider.php
Normal file
32
app/Providers/EventServiceProvider.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The event handler mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'event.name' => [
|
||||
'EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any other events for your application.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(DispatcherContract $events)
|
||||
{
|
||||
parent::boot($events);
|
||||
|
||||
//
|
||||
}
|
||||
}
|
@ -27,7 +27,11 @@ class LoadConfigServiceProvider extends ServiceProvider
|
||||
|
||||
// Set the Segment.com settings.
|
||||
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
|
||||
$this->app->config->set('cachethq/segment::write_key', $segmentRepository->fetch());
|
||||
try {
|
||||
$this->app->config->set('cachethq/segment::write_key', $segmentRepository->fetch());
|
||||
} catch (\GuzzleHttp\Exception\ConnectException $e) {
|
||||
// We may not have any connection. Let's not cry about it.
|
||||
}
|
||||
|
||||
// Override default app values.
|
||||
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
|
63
app/Providers/RouteServiceProvider.php
Normal file
63
app/Providers/RouteServiceProvider.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
use Illuminate\Routing\Router;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* This namespace is applied to the controller routes in your routes file.
|
||||
*
|
||||
* In addition, it is set as the URL generator's root namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'CachetHQ\Cachet\Http\Controllers';
|
||||
|
||||
/**
|
||||
* Define your route model bindings, pattern filters, etc.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
{
|
||||
parent::boot($router);
|
||||
|
||||
$this->registerBindings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register model bindings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function registerBindings()
|
||||
{
|
||||
$this->app->router->model('component', 'CachetHQ\Cachet\Models\Component');
|
||||
$this->app->router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
|
||||
$this->app->router->model('incident', 'CachetHQ\Cachet\Models\Incident');
|
||||
$this->app->router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
|
||||
$this->app->router->model('metric', 'CachetHQ\Cachet\Models\Metric');
|
||||
$this->app->router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
|
||||
$this->app->router->model('setting', 'CachetHQ\Cachet\Models\Setting');
|
||||
$this->app->router->model('user', 'CachetHQ\Cachet\Models\User');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the routes for the application.
|
||||
*
|
||||
* @param \Illuminate\Routing\Router $router
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
{
|
||||
$router->group(['namespace' => $this->namespace], function (Router $router) {
|
||||
foreach (glob(app_path('Http//Routes').'/*.php') as $file) {
|
||||
$this->app->make('CachetHQ\\Cachet\\Http\\Routes\\'.basename($file, '.php'))->map($router);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
40
app/Services/Registrar.php
Normal file
40
app/Services/Registrar.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php namespace CachetHQ\Cachet\Services;
|
||||
|
||||
use CachetHQ\Cachet\User;
|
||||
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
|
||||
use Validator;
|
||||
|
||||
class Registrar implements RegistrarContract
|
||||
{
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
public function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
// Bootstrap variable overrides and custom variables
|
||||
@import "variables";
|
||||
|
||||
// Core variables and mixins
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/variables";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/mixins";
|
||||
|
||||
// Reset and dependencies
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/normalize";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/print";
|
||||
|
||||
// Core CSS
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/scaffolding";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/type";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/code";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/grid";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/tables";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/forms";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/buttons";
|
||||
|
||||
// Components
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/component-animations";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/dropdowns";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/button-groups";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/input-groups";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/navs";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/navbar";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/breadcrumbs";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/pagination";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/pager";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/labels";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/badges";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/jumbotron";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/thumbnails";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/alerts";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/progress-bars";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/media";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/list-group";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/panels";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/responsive-embed";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/wells";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/close";
|
||||
|
||||
// Components w/ JavaScript
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/modals";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/tooltip";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/popovers";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/carousel";
|
||||
|
||||
// Utility classes
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/utilities";
|
||||
@import "../../bower_components/bootstrap-sass/assets/stylesheets/bootstrap/responsive-utilities";
|
@ -1,196 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => getenv('APP_DEBUG') ?: false,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => 'http://localhost',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'fallback_locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => 'kCifbUiHYswooAvSZBQjWZVY1S6aBdnD',
|
||||
|
||||
'cipher' => MCRYPT_RIJNDAEL_128,
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
|
||||
/*
|
||||
* Laravel Framework Service Providers...
|
||||
*/
|
||||
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
|
||||
'Illuminate\Auth\AuthServiceProvider',
|
||||
'Illuminate\Cache\CacheServiceProvider',
|
||||
'Illuminate\Session\CommandsServiceProvider',
|
||||
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
|
||||
'Illuminate\Routing\ControllerServiceProvider',
|
||||
'Illuminate\Cookie\CookieServiceProvider',
|
||||
'Illuminate\Database\DatabaseServiceProvider',
|
||||
'Illuminate\Encryption\EncryptionServiceProvider',
|
||||
'Illuminate\Filesystem\FilesystemServiceProvider',
|
||||
'Illuminate\Hashing\HashServiceProvider',
|
||||
'Illuminate\Html\HtmlServiceProvider',
|
||||
'Illuminate\Log\LogServiceProvider',
|
||||
'Illuminate\Mail\MailServiceProvider',
|
||||
'Illuminate\Database\MigrationServiceProvider',
|
||||
'Illuminate\Pagination\PaginationServiceProvider',
|
||||
'Illuminate\Queue\QueueServiceProvider',
|
||||
'Illuminate\Redis\RedisServiceProvider',
|
||||
'Illuminate\Auth\Reminders\ReminderServiceProvider',
|
||||
'Illuminate\Database\SeedServiceProvider',
|
||||
'Illuminate\Session\SessionServiceProvider',
|
||||
'Illuminate\Translation\TranslationServiceProvider',
|
||||
'Illuminate\Validation\ValidationServiceProvider',
|
||||
'Illuminate\View\ViewServiceProvider',
|
||||
|
||||
/*
|
||||
* Packages Service Providers...
|
||||
*/
|
||||
'Dingo\Api\Provider\ApiServiceProvider',
|
||||
'Fideloper\Proxy\ProxyServiceProvider',
|
||||
'GrahamCampbell\Binput\BinputServiceProvider',
|
||||
'GrahamCampbell\Markdown\MarkdownServiceProvider',
|
||||
'GrahamCampbell\Security\SecurityServiceProvider',
|
||||
'GrahamCampbell\Throttle\ThrottleServiceProvider',
|
||||
'Jenssegers\Date\DateServiceProvider',
|
||||
'McCool\LaravelAutoPresenter\LaravelAutoPresenterServiceProvider',
|
||||
'PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider',
|
||||
'Roumen\Feed\FeedServiceProvider',
|
||||
'Thujohn\Rss\RssServiceProvider',
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
'CachetHQ\Cachet\Providers\AuthServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ConsoleServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RepositoryServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RoutingServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\ViewComposerServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\LoadConfigServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\SettingsServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\SegmentApiServiceProvider',
|
||||
'CachetHQ\Segment\SegmentServiceProvider',
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Service Provider Manifest
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service provider manifest is used by Laravel to lazy load service
|
||||
| providers which are not needed for each request, as well to keep a
|
||||
| list of all of the services. Here, you may set its storage spot.
|
||||
|
|
||||
*/
|
||||
|
||||
'manifest' => storage_path().'/meta',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
'aliases' => [
|
||||
|
||||
'App' => 'Illuminate\Support\Facades\App',
|
||||
'Auth' => 'Illuminate\Support\Facades\Auth',
|
||||
'Form' => 'Illuminate\Support\Facades\Form',
|
||||
'Input' => 'Illuminate\Support\Facades\Input',
|
||||
'Redirect' => 'Illuminate\Support\Facades\Redirect',
|
||||
'Request' => 'Illuminate\Support\Facades\Request',
|
||||
'Response' => 'Illuminate\Support\Facades\Response',
|
||||
'Route' => 'Illuminate\Support\Facades\Route',
|
||||
'Session' => 'Illuminate\Support\Facades\Session',
|
||||
'Setting' => 'CachetHQ\Cachet\Facades\Setting',
|
||||
'Str' => 'Illuminate\Support\Str',
|
||||
|
||||
],
|
||||
|
||||
];
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Authentication Driver
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option controls the authentication driver that will be utilized.
|
||||
| This driver manages the retrieval and authentication of the users
|
||||
| attempting to get access to protected areas of your application.
|
||||
|
|
||||
| Supported: "database", "eloquent"
|
||||
|
|
||||
*/
|
||||
|
||||
'driver' => 'eloquent',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Model
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "Eloquent" authentication driver, we need to know which
|
||||
| Eloquent model should be used to retrieve your users. Of course, it
|
||||
| is often just the "User" model but you may use whatever you like.
|
||||
|
|
||||
*/
|
||||
|
||||
'model' => 'CachetHQ\Cachet\Models\User',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Authentication Table
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When using the "Database" authentication driver, we need to know which
|
||||
| table should be used to retrieve your users. We have chosen a basic
|
||||
| default value but you may easily change it to any table you like.
|
||||
|
|
||||
*/
|
||||
|
||||
'table' => 'users',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reminder Settings
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may set the settings for password reminders, including a view
|
||||
| that should be used as your password reminder e-mail. You will also
|
||||
| be able to set the name of the table that holds the reset tokens.
|
||||
|
|
||||
| The "expire" time is the number of minutes that the reminder should be
|
||||
| considered valid. This security feature keeps tokens short-lived so
|
||||
| they have less time to be guessed. You may change this as needed.
|
||||
|
|
||||
*/
|
||||
|
||||
'reminder' => [
|
||||
|
||||
'email' => 'emails.auth.reminder',
|
||||
|
||||
'table' => 'password_reminders',
|
||||
|
||||
'expire' => 60,
|
||||
|
||||
],
|
||||
|
||||
];
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user