Set slug properly on pirep field and fix validation

This commit is contained in:
Nabeel Shahzad
2018-02-06 10:02:34 -06:00
parent 282421deb8
commit 995d53df3e
4 changed files with 15 additions and 13 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Models;
use Log;
/**
* Class PirepField
*
@@ -37,18 +39,14 @@ class PirepField extends BaseModel
* On creation
*/
static::creating(function (PirepField $model) {
if (!empty($model->slug)) {
$model->slug = str_slug($model->name);
}
$model->slug = str_slug($model->name);
});
/**
* When updating
*/
static::updating(function(PirepField $model) {
if (!empty($model->slug)) {
$model->slug = str_slug($model->name);
}
$model->slug = str_slug($model->name);
});
}
}