Skip to main content

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

Read more here

ploi-deploy/roadmap

527 stars
2 code files
View ploi-deploy/roadmap on GitHub

app/Traits/Sluggable.php

Open in GitHub
use Illuminate\Support\Str;
 
trait Sluggable
{
public function getRouteKeyName()
{
return 'slug';
}
 
public static function bootSluggable()
{
static::created(function ($model) {
if (!$model->slug) {
$model->slug = Str::slug($model->id . ' ' . $model->title);
$model->save();
}
});
}
}

app/Models/Project.php

Open in GitHub
use App\Traits\Sluggable;
use Illuminate\Database\Eloquent\Model;
 
class Project extends Model
{
use Sluggable;
//
}

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.