-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2642 from CachetHQ/incident-components
Create incident_components table
- Loading branch information
Showing
3 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?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. | ||
*/ | ||
|
||
namespace CachetHQ\Cachet\Models; | ||
|
||
use AltThree\Validator\ValidatingTrait; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
/** | ||
* This is the incident component model class. | ||
* | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
class IncidentComponent extends Model | ||
{ | ||
use ValidatingTrait; | ||
|
||
/** | ||
* The attributes that should be casted to native types. | ||
* | ||
* @var string[] | ||
*/ | ||
protected $casts = [ | ||
'incident_id' => 'int', | ||
'component_id' => 'int', | ||
'status_id' => 'int', | ||
]; | ||
|
||
/** | ||
* The fillable properties. | ||
* | ||
* @var string[] | ||
*/ | ||
protected $fillable = [ | ||
'incident_id', | ||
'component_id', | ||
'status_id', | ||
]; | ||
|
||
/** | ||
* The validation rules. | ||
* | ||
* @var string[] | ||
*/ | ||
public $rules = [ | ||
'incident_id' => 'required|int', | ||
'component_id' => 'required|int', | ||
'status_id' => 'required|int', | ||
]; | ||
|
||
/** | ||
* Get the incident relation. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function incident() | ||
{ | ||
return $this->belongsTo(Incident::class); | ||
} | ||
|
||
/** | ||
* Get the component relation. | ||
* | ||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | ||
*/ | ||
public function component() | ||
{ | ||
return $this->belongsTo(Component::class); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
database/migrations/2017_07_18_214718_CreateIncidentComponents.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?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 CreateIncidentComponents extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function up() | ||
{ | ||
Schema::create('incident_components', function (Blueprint $table) { | ||
$table->increments('id'); | ||
$table->integer('incident_id')->unsigned()->index(); | ||
$table->integer('component_id')->unsigned()->index(); | ||
$table->integer('status_id')->unsigned()->index(); | ||
$table->timestamps(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
* | ||
* @return void | ||
*/ | ||
public function down() | ||
{ | ||
Schema::dropIfExists('incident_components'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?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. | ||
*/ | ||
|
||
namespace CachetHQ\Tests\Cachet\Models; | ||
|
||
use AltThree\TestBench\ValidationTrait; | ||
use CachetHQ\Cachet\Models\IncidentComponent; | ||
use CachetHQ\Tests\Cachet\AbstractTestCase; | ||
|
||
/** | ||
* This is the incident component model test class. | ||
* | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
class IncidentComponentTest extends AbstractTestCase | ||
{ | ||
use ValidationTrait; | ||
|
||
public function testValidation() | ||
{ | ||
$this->checkRules(new IncidentComponent()); | ||
} | ||
} |