Change setting table ID to string, handle the converison of . to _

This commit is contained in:
Nabeel Shahzad
2017-12-31 11:09:56 -06:00
parent 528a7c7440
commit 948338d2b6
5 changed files with 53 additions and 30 deletions

View File

@@ -1,16 +1,11 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: nshahzad
* Date: 12/9/17
* Time: 6:24 PM
*/
namespace App\Models;
class Setting extends BaseModel
{
public $table = 'settings';
public $incrementing = false;
public $fillable = [
'name',
@@ -22,4 +17,18 @@ class Setting extends BaseModel
'description',
];
protected static function boot()
{
parent::boot();
/**
* Make sure any dots are replaced with underscores
*/
static::creating(function (Setting $model) {
if (!empty($model->id)) {
$model->id = str_replace('.', '_', strtolower($model->id));
}
});
}
}