Create IncidentTemplate migration and model.

This commit is contained in:
James Brooks 2014-11-24 16:49:07 +00:00
parent cbb7032119
commit 0bb95937b0
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateIncidentTemplatesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('incident_templates', function(Blueprint $table)
{
$table->increments('id');
$table->string('name')->nullable(false);
$table->string('slug', 50)->nullable(false);
$table->longText('template')->nullable(false);
$table->timestamps();
$table->index('slug');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('incident_templates');
}
}

View File

@ -0,0 +1,11 @@
<?php
class IncidentTemplate extends Eloquemt {
public static function boot() {
parent::boot();
self::on('saving', function($template) {
$template->slug = Str::slug($template->name);
});
}
}