Make sure the subfleet name doesn't have spaces
This commit is contained in:
@@ -39,6 +39,31 @@ class Subfleet extends BaseModel
|
|||||||
'type' => 'required',
|
'type' => 'required',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Modify some fields on the fly. Make sure the subfleet
|
||||||
|
* names don't have spaces in them.
|
||||||
|
*/
|
||||||
|
public static function boot()
|
||||||
|
{
|
||||||
|
parent::boot();
|
||||||
|
|
||||||
|
static::creating(function ($model) {
|
||||||
|
if (filled($model->name)) {
|
||||||
|
$model->name = str_replace(' ', '_', $model->name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
static::updating(function ($model) {
|
||||||
|
if (filled($model->name)) {
|
||||||
|
$model->name = str_replace(' ', '_', $model->name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Relationships
|
||||||
|
*/
|
||||||
|
|
||||||
public function aircraft()
|
public function aircraft()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Aircraft::class, 'subfleet_id');
|
return $this->hasMany(Aircraft::class, 'subfleet_id');
|
||||||
|
|||||||
Reference in New Issue
Block a user