curated jobs and tags
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
protected $fillable = ['name', 'slug'];
|
||||
|
||||
protected static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
static::creating(function ($tag) {
|
||||
if (empty($tag->slug)) {
|
||||
$tag->slug = Str::slug($tag->name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function jobs(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Job::class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user