Added per-component subscriptions. Closes #734

This commit is contained in:
James Brooks
2016-01-10 15:54:54 +00:00
committed by James Brooks
parent e5c137f82b
commit ac3888f7c8
29 changed files with 620 additions and 17 deletions

View File

@@ -16,6 +16,7 @@ use CachetHQ\Cachet\Models\IncidentTemplate;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Cachet\Models\Subscription;
use CachetHQ\Cachet\Models\User;
use Carbon\Carbon;
@@ -79,6 +80,16 @@ $factory->define(Subscriber::class, function ($faker) {
];
});
$factory->define(Subscription::class, function ($faker) {
$user = factory(Subscriber::class)->create();
$component = factory(Component::class)->create();
return [
'subscriber_id' => $user->id,
'component_id' => $component->id,
];
});
$factory->define(User::class, function ($faker) {
return [
'username' => $faker->userName,

View File

@@ -0,0 +1,42 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateSubscriptionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('subscriptions', function (Blueprint $table) {
$table->increments('id');
$table->integer('subscriber_id')->unsigned()->index();
$table->integer('component_id')->unsigned()->index();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('subscriptions');
}
}