blue-twilight/app/ModelObservers/AlbumObserver.php

36 lines
664 B
PHP

<?php
namespace App\ModelObservers;
use App\Album;
class AlbumObserver
{
public function creating(Album $album)
{
// Re-generate the alias and path
if (is_null($album->url_alias))
{
$album->generateAlias();
}
if (is_null($album->url_path))
{
$album->generateUrlPath();
}
}
public function updating(Album $album)
{
// Re-generate the alias and path
if (is_null($album->url_alias))
{
$album->generateAlias();
}
if (is_null($album->url_path))
{
$album->generateUrlPath();
}
}
}