Fix PIREP submission and field slug problems on PIREP edit

This commit is contained in:
Nabeel Shahzad
2018-05-30 14:00:20 -05:00
parent b7a6cb4fbc
commit a083f9c671
13 changed files with 102 additions and 47 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace App\Models\Observers;
/**
* Create a slug from a name
* @package App\Models\Observers
*/
class Sluggable
{
/**
* @param $model
*/
public function creating($model): void
{
$model->slug = str_slug($model->name);
}
/**
* @param $model
*/
public function updating($model): void
{
$model->slug = str_slug($model->name);
}
/**
* @param $name
*/
public function setNameAttribute($name): void
{
$this->attributes['name'] = $name;
$this->attributes['slug'] = str_slug($name);
}
}