51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Relations\HasOne;
|
|
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
#[Fillable([
|
|
'buyer_id', 'title', 'status', 'service_category', 'location', 'starts_at',
|
|
'time_window', 'scope', 'required_skills', 'required_tools', 'deliverables',
|
|
'payment_terms', 'vendor_onboarding', 'visibility',
|
|
])]
|
|
class JobPost extends Model
|
|
{
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'starts_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function buyer(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'buyer_id');
|
|
}
|
|
|
|
public function quotes(): HasMany
|
|
{
|
|
return $this->hasMany(Quote::class);
|
|
}
|
|
|
|
public function workOrder(): HasOne
|
|
{
|
|
return $this->hasOne(WorkOrder::class);
|
|
}
|
|
|
|
public function comments(): MorphMany
|
|
{
|
|
return $this->morphMany(Comment::class, 'commentable');
|
|
}
|
|
|
|
public function attachments(): MorphMany
|
|
{
|
|
return $this->morphMany(Attachment::class, 'attachable');
|
|
}
|
|
}
|