@@ -5,7 +5,7 @@ namespace CachetHQ\Cachet\Controllers\Api;
|
||||
use CachetHQ\Cachet\Repositories\Component\ComponentRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Input;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class ComponentController extends Controller
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace CachetHQ\Cachet\Controllers\Api;
|
||||
use CachetHQ\Cachet\Repositories\Incident\IncidentRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Input;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class IncidentController extends Controller
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace CachetHQ\Cachet\Controllers\Api;
|
||||
use CachetHQ\Cachet\Repositories\Metric\MetricRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Input;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class MetricController extends Controller
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace CachetHQ\Cachet\Controllers\Api;
|
||||
use CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository;
|
||||
use Dingo\Api\Routing\ControllerTrait;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Input;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
|
||||
class MetricPointController extends Controller
|
||||
{
|
||||
|
||||
@@ -8,13 +8,16 @@ class EmailService implements ServiceInterface
|
||||
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function unregister()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function fire($data)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ class RoutingServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function boot()
|
||||
|
||||
@@ -10,6 +10,7 @@ class IncidentTransformer extends TransformerAbstract
|
||||
public function transform(Incident $incident)
|
||||
{
|
||||
$component = $incident->component;
|
||||
|
||||
if ($component) {
|
||||
$transformer = $component->getTransformer();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateIncidentsTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateComponentsTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSettingsTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateWebHooksTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateWebHookResponsesTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateUsersTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateIncidentTemplatesTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMetricsTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateMetricPointsTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UserIdColumnForComponents extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UserIdColumnForIncidents extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSubscribersTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateServicesTable extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableIncidentsRenameComponentColumn extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableIncidentsRemoveDefaultComponent extends Migration
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateSessionTable extends Migration
|
||||
{
|
||||
@@ -11,10 +13,10 @@ class CreateSessionTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('sessions', function ($t) {
|
||||
$t->string('id')->unique();
|
||||
$t->text('payload');
|
||||
$t->integer('last_activity');
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->unique();
|
||||
$table->text('payload');
|
||||
$table->integer('last_activity');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableComponentsAddDeletedAt extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableComponentsAddMetaColumns extends Migration
|
||||
{
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AlterTableSettingsValueLongText extends Migration
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableComponentsAddOrderColumn extends Migration
|
||||
{
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
use CachetHQ\Cachet\Transformers\ComponentTransformer;
|
||||
use Dingo\Api\Transformer\TransformableInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Component extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface
|
||||
class Component extends Model implements TransformableInterface
|
||||
{
|
||||
use ValidatingTrait;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
protected $rules = [
|
||||
'user_id' => 'integer|required',
|
||||
@@ -14,20 +17,12 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
|
||||
'link' => 'url',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'description',
|
||||
'status',
|
||||
'user_id',
|
||||
'tags',
|
||||
'link',
|
||||
'order',
|
||||
];
|
||||
protected $fillable = ['name', 'description', 'status', 'user_id', 'tags', 'link', 'order'];
|
||||
|
||||
/**
|
||||
* Lookup all of the incidents reported on the component.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Relations
|
||||
* @return \Illuminate\Database\Eloquent\Relations
|
||||
*/
|
||||
public function incidents()
|
||||
{
|
||||
@@ -37,10 +32,10 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
|
||||
/**
|
||||
* Finds all components by status.
|
||||
*
|
||||
* @param Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $status
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $status
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Builder
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeStatus($query, $status)
|
||||
{
|
||||
@@ -50,10 +45,10 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
|
||||
/**
|
||||
* Finds all components which don't have the given status.
|
||||
*
|
||||
* @param Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $status
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $status
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Builder
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeNotStatus($query, $status)
|
||||
{
|
||||
@@ -73,10 +68,10 @@ class Component extends Eloquent implements \Dingo\Api\Transformer\Transformable
|
||||
/**
|
||||
* Get the transformer instance.
|
||||
*
|
||||
* @return ComponentTransformer
|
||||
* @return \CachetHQ\Cachet\Transformers\ComponentTransformer
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
return new CachetHQ\Cachet\Transformers\ComponentTransformer();
|
||||
return new ComponentTransformer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
use CachetHQ\Cachet\Transformers\IncidentTransformer;
|
||||
use Dingo\Api\Transformer\TransformableInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Incident extends Eloquent implements TransformableInterface
|
||||
class Incident extends Model implements TransformableInterface
|
||||
{
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
@@ -74,7 +76,7 @@ class Incident extends Eloquent implements TransformableInterface
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
return new CachetHQ\Cachet\Transformers\IncidentTransformer();
|
||||
return new IncidentTransformer();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class IncidentTemplate extends Eloquent
|
||||
class IncidentTemplate extends Model
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
@@ -11,10 +12,7 @@ class IncidentTemplate extends Eloquent
|
||||
'template' => 'required',
|
||||
];
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'template',
|
||||
];
|
||||
protected $fillable = ['name', 'template'];
|
||||
|
||||
/**
|
||||
* Overrides the models boot method.
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<?php
|
||||
|
||||
use CachetHQ\Cachet\Transformers\MetricTransformer;
|
||||
use Dingo\Api\Transformer\TransformableInterface;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInterface
|
||||
class Metric extends Model implements TransformableInterface
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
@@ -17,7 +20,7 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
|
||||
/**
|
||||
* Metrics contain many metric points.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Builder
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function points()
|
||||
{
|
||||
@@ -37,10 +40,10 @@ class Metric extends Eloquent implements \Dingo\Api\Transformer\TransformableInt
|
||||
/**
|
||||
* Get the transformer instance.
|
||||
*
|
||||
* @return CachetHQ\Cachet\Transformers\MetricTransformer
|
||||
* @return \CachetHQ\Cachet\Transformers\MetricTransformer
|
||||
*/
|
||||
public function getTransformer()
|
||||
{
|
||||
return new CachetHQ\Cachet\Transformers\MetricTransformer();
|
||||
return new MetricTransformer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class MetricPoint extends Eloquent
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class MetricPoint extends Model
|
||||
{
|
||||
/**
|
||||
* A metric point belongs to a metric unit.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Service extends Eloquent
|
||||
class Service extends Model
|
||||
{
|
||||
use ValidatingTrait;
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Setting extends Eloquent
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Setting extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'value'];
|
||||
|
||||
@@ -20,7 +22,7 @@ class Setting extends Eloquent
|
||||
// First try finding the setting in the database.
|
||||
try {
|
||||
$setting = self::whereName($settingName)->first()->value;
|
||||
} catch (\ErrorException $e) {
|
||||
} catch (ErrorException $e) {
|
||||
// If we don't have a setting, check the env (fallback for original version)
|
||||
if ($checkEnv) {
|
||||
if (!($setting = getenv(strtoupper($settingName)))) {
|
||||
@@ -39,14 +41,12 @@ class Setting extends Eloquent
|
||||
*
|
||||
* @param string $setting
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function unknownSettingException($setting)
|
||||
{
|
||||
throw new \Exception(
|
||||
sprintf('Unknown setting %s', $setting)
|
||||
);
|
||||
throw new Exception(sprintf('Unknown setting %s', $setting));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
use Watson\Validating\ValidatingTrait;
|
||||
|
||||
class Subscriber extends Eloquent
|
||||
class Subscriber extends Model
|
||||
{
|
||||
use ValidatingTrait;
|
||||
use SoftDeletingTrait;
|
||||
use SoftDeletingTrait, ValidatingTrait;
|
||||
|
||||
protected $rules = [
|
||||
'email' => 'required|email',
|
||||
|
||||
@@ -4,8 +4,10 @@ use Illuminate\Auth\Reminders\RemindableInterface;
|
||||
use Illuminate\Auth\Reminders\RemindableTrait;
|
||||
use Illuminate\Auth\UserInterface;
|
||||
use Illuminate\Auth\UserTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
class User extends Model implements UserInterface, RemindableInterface
|
||||
{
|
||||
use UserTrait, RemindableTrait;
|
||||
|
||||
@@ -33,7 +35,7 @@ class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
/**
|
||||
* Hash any password being inserted by default.
|
||||
*
|
||||
* @param string @password
|
||||
* @param string $password
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@@ -51,10 +53,6 @@ class User extends Eloquent implements UserInterface, RemindableInterface
|
||||
*/
|
||||
public function getGravatarAttribute($size = 200)
|
||||
{
|
||||
return sprintf(
|
||||
'https://www.gravatar.com/avatar/%s?size=%d',
|
||||
md5($this->email),
|
||||
$size
|
||||
);
|
||||
return sprintf('https://www.gravatar.com/avatar/%s?size=%d', md5($this->email), $size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<?php
|
||||
|
||||
class WebHook extends Eloquent
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WebHook extends Model
|
||||
{
|
||||
// Request Methods.
|
||||
const HEAD = 0;
|
||||
@@ -13,7 +17,7 @@ class WebHook extends Eloquent
|
||||
/**
|
||||
* Returns all responses for a WebHook.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Builder
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function response()
|
||||
{
|
||||
@@ -23,9 +27,9 @@ class WebHook extends Eloquent
|
||||
/**
|
||||
* Returns all active hooks.
|
||||
*
|
||||
* @param Illuminate\Database\Eloquent\Builder $query
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Builder
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeActive($query)
|
||||
{
|
||||
@@ -35,7 +39,7 @@ class WebHook extends Eloquent
|
||||
/**
|
||||
* Setups a Ping event that is fired upon a web hook.
|
||||
*
|
||||
* @return array result of the ping
|
||||
* @return object
|
||||
*/
|
||||
public function ping()
|
||||
{
|
||||
@@ -54,7 +58,7 @@ class WebHook extends Eloquent
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$client = new Client();
|
||||
$request = $client->createRequest($this->requestMethod, $this->endpoint, [
|
||||
'headers' => [
|
||||
'X-Cachet-Event' => $eventType,
|
||||
@@ -64,7 +68,7 @@ class WebHook extends Eloquent
|
||||
|
||||
try {
|
||||
$response = $client->send($request);
|
||||
} catch (\GuzzleHttp\Exception\ClientException $e) {
|
||||
} catch (ClientException $e) {
|
||||
// Do nothing with the exception, we want it.
|
||||
$response = $e->getResponse();
|
||||
}
|
||||
@@ -72,14 +76,14 @@ class WebHook extends Eloquent
|
||||
$timeTaken = microtime(true) - $startTime;
|
||||
|
||||
// Store the request
|
||||
$hookResponse = new WebHookResponse();
|
||||
$hookResponse->web_hook_id = $this->id;
|
||||
$hookResponse->response_code = $response->getStatusCode();
|
||||
$hookResponse->sent_headers = json_encode($request->getHeaders());
|
||||
$hookResponse->sent_body = json_encode($data);
|
||||
$hookResponse->recv_headers = json_encode($response->getHeaders());
|
||||
$hookResponse->recv_body = json_encode($response->getBody());
|
||||
$hookResponse->time_taken = $timeTaken;
|
||||
$hookResponse = new WebHookResponse();
|
||||
$hookResponse->web_hook_id = $this->id;
|
||||
$hookResponse->response_code = $response->getStatusCode();
|
||||
$hookResponse->sent_headers = json_encode($request->getHeaders());
|
||||
$hookResponse->sent_body = json_encode($data);
|
||||
$hookResponse->recv_headers = json_encode($response->getHeaders());
|
||||
$hookResponse->recv_body = json_encode($response->getBody());
|
||||
$hookResponse->time_taken = $timeTaken;
|
||||
$hookResponse->save();
|
||||
|
||||
return $hookResponse;
|
||||
@@ -88,7 +92,7 @@ class WebHook extends Eloquent
|
||||
/**
|
||||
* Returns a human readable request type name.
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return string HEAD, GET, POST, DELETE, PATCH, PUT etc
|
||||
*/
|
||||
@@ -98,29 +102,19 @@ class WebHook extends Eloquent
|
||||
|
||||
switch ($this->request_type) {
|
||||
case self::HEAD:
|
||||
$requestMethod = 'HEAD';
|
||||
break;
|
||||
return 'HEAD';
|
||||
case self::GET:
|
||||
$requestMethod = 'GET';
|
||||
break;
|
||||
return 'GET';
|
||||
case self::POST:
|
||||
$requestMethod = 'POST';
|
||||
break;
|
||||
return 'POST';
|
||||
case self::PATCH:
|
||||
$requestMethod = 'PATCH';
|
||||
break;
|
||||
return 'PATCH';
|
||||
case self::PUT:
|
||||
$requestMethod = 'PUT';
|
||||
break;
|
||||
return 'PUT';
|
||||
case self::DELETE:
|
||||
$requestMethod = 'DELETE';
|
||||
break;
|
||||
|
||||
return 'DELETE';
|
||||
default:
|
||||
throw new Exception('Unknown request type value: '.$this->request_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return $requestMethod;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
class WebHookResponse extends Eloquent
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class WebHookResponse extends Model
|
||||
{
|
||||
/**
|
||||
* Returns the hook that a response belongs to.
|
||||
*
|
||||
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function hook()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user