phpvms/app/Models/Observers/Sluggable.php
Nabeel S 45873431e4
Add public/private pages #641 (#644)
* Add public/private pages #641

* Cleanup the form requests
2020-03-28 13:03:52 -04:00

37 lines
605 B
PHP

<?php
namespace App\Models\Observers;
/**
* Create a slug from a name
*
* @property object attributes
*/
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);
}
}