Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

devhub-az/devhub

24 stars
2 code files
View devhub-az/devhub on GitHub

app/Observers/ArticleObserver.php

Open in GitHub
use App\Models\Article;
use Illuminate\Support\Str;
use Ramsey\Uuid\Uuid;
 
class ArticleObserver
{
public function saving(Article $article)
{
$article->id = Uuid::uuid4();
$article->slug = Str::slug($article->title);
}
}

app/Providers/AppServiceProvider.php

Open in GitHub
use App\Observers\ArticleObserver;
use Illuminate\Support\ServiceProvider;
 
class AppServiceProvider extends ServiceProvider
{
///
public function boot()
{
Article::observe(ArticleObserver::class);
//
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.