49 lines
963 B
PHP
49 lines
963 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class UserJobAlert extends Model
|
|
{
|
|
protected $fillable = [
|
|
'user_id',
|
|
'keywords',
|
|
'location',
|
|
'job_category_id',
|
|
'frequency',
|
|
'is_active',
|
|
'last_sent_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'is_active' => 'boolean',
|
|
'last_sent_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* Get the user who created the alert.
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class);
|
|
}
|
|
|
|
/**
|
|
* Get the category for this alert.
|
|
*/
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(JobCategory::class, 'job_category_id');
|
|
}
|
|
|
|
/**
|
|
* Scope a query to only include active alerts.
|
|
*/
|
|
public function scopeActive($query)
|
|
{
|
|
return $query->where('is_active', true);
|
|
}
|
|
}
|