feat: automatic tenant_id sync for candidates from job position
This commit is contained in:
@@ -15,6 +15,18 @@ use App\Traits\BelongsToTenant;
|
|||||||
class Candidate extends Model
|
class Candidate extends Model
|
||||||
{
|
{
|
||||||
use HasFactory, BelongsToTenant;
|
use HasFactory, BelongsToTenant;
|
||||||
|
|
||||||
|
protected static function booted()
|
||||||
|
{
|
||||||
|
static::creating(function ($candidate) {
|
||||||
|
if ($candidate->job_position_id && !$candidate->tenant_id) {
|
||||||
|
$jobPosition = JobPosition::find($candidate->job_position_id);
|
||||||
|
if ($jobPosition) {
|
||||||
|
$candidate->tenant_id = $jobPosition->tenant_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'ai_analysis' => 'array',
|
'ai_analysis' => 'array',
|
||||||
|
|||||||
Reference in New Issue
Block a user