Merge pull request #693 from cachethq/no-user-id

Closes #688 - Drop user_id column
This commit is contained in:
James Brooks
2015-06-10 13:39:24 +01:00
12 changed files with 78 additions and 27 deletions

View File

@@ -16,7 +16,6 @@ use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Tag;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@@ -116,7 +115,6 @@ class ComponentController extends AbstractController
public function updateComponentAction(Component $component)
{
$_component = Binput::get('component');
$_component['user_id'] = Auth::user()->id;
$tags = array_pull($_component, 'tags');
$component->update($_component);
@@ -185,7 +183,6 @@ class ComponentController extends AbstractController
public function createComponentAction()
{
$_component = Binput::get('component');
$_component['user_id'] = Auth::user()->id;
// We deal with tags separately.
$tags = array_pull($_component, 'tags');

View File

@@ -18,7 +18,6 @@ use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@@ -113,7 +112,6 @@ class IncidentController extends AbstractController
public function createIncidentAction()
{
$incidentData = Binput::get('incident');
$incidentData['user_id'] = Auth::user()->id;
$componentStatus = array_pull($incidentData, 'component_status');
if (array_has($incidentData, 'created_at') && $incidentData['created_at']) {
@@ -294,7 +292,6 @@ class IncidentController extends AbstractController
public function editIncidentAction(Incident $incident)
{
$incidentData = Binput::get('incident');
$incidentData['user_id'] = Auth::user()->id;
if (array_has($incidentData, 'created_at') && $incidentData['created_at']) {
$incidentDate = Date::createFromFormat('d/m/Y H:i', $incidentData['created_at'], Setting::get('app_timezone'))->setTimezone(Config::get('app.timezone'));

View File

@@ -16,7 +16,6 @@ use CachetHQ\Cachet\Http\Controllers\AbstractController;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
use GrahamCampbell\Binput\Facades\Binput;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\View;
@@ -93,7 +92,6 @@ class ScheduleController extends AbstractController
public function addScheduleAction()
{
$scheduleData = Binput::get('incident');
$scheduleData['user_id'] = Auth::user()->id;
// Parse the schedule date.
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at'], Setting::get('app_timezone'))
->setTimezone(Config::get('app.timezone'));
@@ -169,7 +167,6 @@ class ScheduleController extends AbstractController
public function editScheduleAction(Incident $schedule)
{
$scheduleData = Binput::get('incident');
$scheduleData['user_id'] = Auth::user()->id;
// Parse the schedule date.
$scheduledAt = Date::createFromFormat('d/m/Y H:i', $scheduleData['scheduled_at'], Setting::get('app_timezone'))
->setTimezone(Config::get('app.timezone'));

View File

@@ -57,7 +57,6 @@ class ComponentController extends AbstractApiController
public function postComponents(Guard $auth)
{
$componentData = Binput::except('tags');
$componentData['user_id'] = $auth->user()->id;
try {
$component = Component::create($componentData);

View File

@@ -57,7 +57,6 @@ class IncidentController extends AbstractApiController
public function postIncidents(Guard $auth)
{
$incidentData = Binput::all();
$incidentData['user_id'] = $auth->user()->id;
try {
$incident = Incident::create($incidentData);

View File

@@ -19,7 +19,6 @@ use Watson\Validating\ValidatingTrait;
/**
* @property int $id
* @property int $user_id
* @property string $name
* @property string $description
* @property int $status
@@ -40,7 +39,6 @@ class Component extends Model implements HasPresenter
* @var string[]
*/
protected $rules = [
'user_id' => 'integer|required',
'name' => 'required|string',
'status' => 'integer|required',
'link' => 'url',
@@ -55,7 +53,6 @@ class Component extends Model implements HasPresenter
'name',
'description',
'status',
'user_id',
'tags',
'link',
'order',

View File

@@ -23,7 +23,6 @@ use Watson\Validating\ValidatingTrait;
* @property string $name
* @property int $status
* @property string $message
* @property int $user_id
* @property \Carbon\Carbon $scheduled_at
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
@@ -40,7 +39,6 @@ class Incident extends Model implements HasPresenter
* @var string[]
*/
protected $rules = [
'user_id' => 'required|integer',
'component_id' => 'integer',
'name' => 'required',
'status' => 'required|integer',
@@ -53,7 +51,6 @@ class Incident extends Model implements HasPresenter
* @var string[]
*/
protected $fillable = [
'user_id',
'component_id',
'name',
'status',

View File

@@ -28,7 +28,6 @@ $factory->define('CachetHQ\Cachet\Models\Component', function ($faker) {
'link' => $faker->url(),
'status' => 1,
'order' => 0,
'user_id' => 1,
];
});
@@ -37,7 +36,6 @@ $factory->define('CachetHQ\Cachet\Models\Incident', function ($faker) {
'name' => $faker->sentence(),
'message' => $faker->paragraph(),
'status' => 1,
'user_id' => 1,
];
});

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Cachet HQ <support@cachethq.io>
*
* 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 AlterTableComponentsDropUserIdColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('components', function (Blueprint $table) {
$table->dropColumn('user_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Cachet HQ <support@cachethq.io>
*
* 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 AlterTableIncidentsDropUserIdColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('incidents', function (Blueprint $table) {
$table->dropColumn('user_id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View File

@@ -27,7 +27,6 @@ class ComponentTableSeeder extends Seeder
'name' => 'API',
'description' => 'Used by third-parties to connect to us',
'status' => 1,
'user_id' => 1,
'order' => 0,
'group_id' => 0,
'link' => '',
@@ -35,7 +34,6 @@ class ComponentTableSeeder extends Seeder
'name' => 'Documentation',
'description' => 'Kindly powered by Readme.io',
'status' => 1,
'user_id' => 1,
'order' => 0,
'group_id' => 0,
'link' => 'https://docs.cachethq.io',
@@ -43,7 +41,6 @@ class ComponentTableSeeder extends Seeder
'name' => 'Website',
'description' => '',
'status' => 1,
'user_id' => 1,
'order' => 0,
'group_id' => 0,
'link' => 'https://cachethq.io',
@@ -51,7 +48,6 @@ class ComponentTableSeeder extends Seeder
'name' => 'Blog',
'description' => 'The Cachet HQ blog.',
'status' => 1,
'user_id' => 1,
'order' => 0,
'group_id' => 0,
'link' => 'https://blog.cachethq.io',

View File

@@ -28,7 +28,6 @@ class IncidentTableSeeder extends Seeder
'message' => 'We totally nailed the fix.',
'status' => 4,
'component_id' => 0,
'user_id' => 1,
'scheduled_at' => null,
],
[
@@ -36,7 +35,6 @@ class IncidentTableSeeder extends Seeder
'message' => "We're checking that our fix will first work.",
'status' => 3,
'component_id' => 0,
'user_id' => 1,
'scheduled_at' => null,
],
[
@@ -44,14 +42,12 @@ class IncidentTableSeeder extends Seeder
'message' => "We've found the problem, so we're looking at it.",
'status' => 2,
'component_id' => 0,
'user_id' => 1,
'scheduled_at' => null,
],
[
'name' => 'Test Incident',
'message' => 'Something went wrong, oh noes.',
'component_id' => 0,
'user_id' => 1,
'scheduled_at' => null,
],
];