Rename component.component to component_id with relationship name change
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class AlterTableIncidentsRenameComponentColumn extends Migration {
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('incidents', function(Blueprint $table)
|
||||
{
|
||||
DB::statement("ALTER TABLE `incidents` CHANGE `component` `component_id` TINYINT(4) NOT NULL DEFAULT '1'");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('incidents', function(Blueprint $table)
|
||||
{
|
||||
DB::statement("ALTER TABLE `incidents` CHANGE `component_id` `component` TINYINT(4) NOT NULL DEFAULT '1'");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,11 +8,11 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
|
||||
use Illuminate\Database\Eloquent\SoftDeletingTrait;
|
||||
|
||||
protected $rules = [
|
||||
'user_id' => 'required|integer',
|
||||
'component' => 'required|integer',
|
||||
'name' => 'required',
|
||||
'status' => 'required|integer',
|
||||
'message' => 'required',
|
||||
'user_id' => 'required|integer',
|
||||
'component_id' => 'required|integer',
|
||||
'name' => 'required',
|
||||
'status' => 'required|integer',
|
||||
'message' => 'required',
|
||||
];
|
||||
|
||||
protected $fillable = ['component', 'name', 'status', 'message'];
|
||||
@@ -23,8 +23,8 @@ class Incident extends Eloquent implements \Dingo\Api\Transformer\TransformableI
|
||||
* An incident belongs to a component.
|
||||
* @return Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||
*/
|
||||
public function parent() {
|
||||
return $this->belongsTo('Component', 'component', 'id');
|
||||
public function component() {
|
||||
return $this->belongsTo('Component', 'component_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user