migrant-web/app/Models/Worker.php
2026-06-01 15:24:03 +05:30

74 lines
1.5 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Worker extends Model
{
use HasFactory, SoftDeletes;
protected $fillable = [
'name',
'email',
'phone',
'language',
'password',
'nationality',
'age',
'salary',
'availability',
'experience',
'religion',
'bio',
'category_id',
'verified',
'status',
'api_token',
];
protected $hidden = [
'password',
'api_token', // Hide from public serialization, returned only during auth endpoints specifically
];
protected $casts = [
'verified' => 'boolean',
'salary' => 'decimal:2',
'password' => 'hashed',
];
public function category()
{
return $this->belongsTo(WorkerCategory::class, 'category_id');
}
public function skills()
{
return $this->belongsToMany(Skill::class, 'worker_skills');
}
public function documents()
{
return $this->hasMany(WorkerDocument::class);
}
// Relationship for job offers received
public function offers()
{
return $this->hasMany(JobOffer::class, 'worker_id');
}
public function reviews()
{
return $this->hasMany(Review::class);
}
public function profileViews()
{
return $this->hasMany(ProfileView::class);
}
}