66 lines
1.2 KiB
PHP
66 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Letter extends Model
|
|
{
|
|
use HasFactory, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'project_id',
|
|
'parent_id',
|
|
'type',
|
|
'subject',
|
|
'content',
|
|
'sender',
|
|
'recipient',
|
|
'date',
|
|
'reference_number',
|
|
'status',
|
|
'created_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'date' => 'date',
|
|
];
|
|
|
|
public function tenant()
|
|
{
|
|
return $this->belongsTo(Tenant::class);
|
|
}
|
|
|
|
public function project()
|
|
{
|
|
return $this->belongsTo(Project::class);
|
|
}
|
|
|
|
public function parentLetter()
|
|
{
|
|
return $this->belongsTo(Letter::class, 'parent_id');
|
|
}
|
|
|
|
public function replies()
|
|
{
|
|
return $this->hasMany(Letter::class, 'parent_id');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
public function attachments()
|
|
{
|
|
return $this->hasMany(LetterAttachment::class);
|
|
}
|
|
|
|
public function createdBy()
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
} |