Save the user ID of who created the component or incident
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
*/
|
||||
public function postComponents() {
|
||||
$component = new Component(Input::all());
|
||||
$component->user_id = $this->auth->user()->id;
|
||||
if ($component->isValid()) {
|
||||
$component->saveOrFail();
|
||||
return $component;
|
||||
@@ -82,6 +83,7 @@
|
||||
*/
|
||||
public function postIncidents() {
|
||||
$incident = new Incident(Input::all());
|
||||
$incident->user_id = $this->auth->user()->id;
|
||||
if ($incident->isValid()) {
|
||||
$incident->saveOrFail();
|
||||
return $incident;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UserIdColumnForComponents extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('components', function(Blueprint $table)
|
||||
{
|
||||
$table->unsignedInteger('user_id')->nullable();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('NO ACTION');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('components', function(Blueprint $table)
|
||||
{
|
||||
$table->dropColumn('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class UserIdColumnForIncidents extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('incidents', function(Blueprint $table)
|
||||
{
|
||||
$table->unsignedInteger('user_id')->nullable();
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('SET NULL')->onUpdate('NO ACTION');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('incidents', function(Blueprint $table)
|
||||
{
|
||||
$table->dropColumn('user_id');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,11 +6,12 @@
|
||||
use ValidatingTrait;
|
||||
|
||||
protected $rules = [
|
||||
'user_id' => 'required|integer',
|
||||
'name' => 'required',
|
||||
'status' => 'required|integer'
|
||||
];
|
||||
|
||||
protected $fillable = ['name', 'description', 'status'];
|
||||
protected $fillable = ['user_id', 'name', 'description', 'status'];
|
||||
|
||||
/**
|
||||
* Lookup all of the incidents reported on the component.
|
||||
|
||||
@@ -7,13 +7,14 @@
|
||||
use \Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
|
||||
protected $rules = [
|
||||
'user_id' => 'required|integer',
|
||||
'component' => 'required|integer',
|
||||
'name' => 'required',
|
||||
'status' => 'required|integer',
|
||||
'message' => 'required',
|
||||
];
|
||||
|
||||
protected $fillable = ['component', 'name', 'status', 'message'];
|
||||
protected $fillable = ['user_id', 'component', 'name', 'status', 'message'];
|
||||
|
||||
/**
|
||||
* An incident belongs to a component.
|
||||
|
||||
Reference in New Issue
Block a user