curated jobs and tags
This commit is contained in:
@@ -46,6 +46,7 @@ class Job extends Model
|
||||
'posted_at',
|
||||
'expires_at',
|
||||
'remote_allowed',
|
||||
'is_curated',
|
||||
'experience_level',
|
||||
'job_category_id',
|
||||
'job_location_id',
|
||||
@@ -56,6 +57,7 @@ class Job extends Model
|
||||
'posted_at' => 'datetime',
|
||||
'expires_at' => 'datetime',
|
||||
'remote_allowed' => 'boolean',
|
||||
'is_curated' => 'boolean',
|
||||
'salary_min' => 'decimal:2',
|
||||
'salary_max' => 'decimal:2',
|
||||
];
|
||||
@@ -93,6 +95,14 @@ class Job extends Model
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tags for this job.
|
||||
*/
|
||||
public function tags(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Tag::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include active jobs.
|
||||
*/
|
||||
@@ -104,6 +114,14 @@ class Job extends Model
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include uncurated jobs.
|
||||
*/
|
||||
public function scopeUncurated($query)
|
||||
{
|
||||
return $query->where('is_curated', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include remote jobs.
|
||||
*/
|
||||
|
||||
@@ -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