Files
minicrm/app/Models/Feedback.php
2026-05-01 04:33:00 +00:00

64 lines
1.7 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
#[Fillable(['customer_id', 'customer_product_id', 'contract_id', 'feedback_channel_id', 'assigned_to', 'title', 'content', 'status', 'current_department_id', 'is_escalated'])]
class Feedback extends Model
{
public function customer(): BelongsTo
{
return $this->belongsTo(Customer::class);
}
public function customerProduct(): BelongsTo
{
return $this->belongsTo(CustomerProduct::class, 'customer_product_id');
}
public function contract(): BelongsTo
{
return $this->belongsTo(Contract::class);
}
public function feedbackChannel(): BelongsTo
{
return $this->belongsTo(FeedbackChannel::class);
}
public function assignedTo(): BelongsTo
{
return $this->belongsTo(User::class, 'assigned_to');
}
public function currentDepartment(): BelongsTo
{
return $this->belongsTo(Department::class, 'current_department_id');
}
public function transferLogs(): HasMany
{
return $this->hasMany(TicketTransferLog::class);
}
public function interactions(): HasMany
{
return $this->hasMany(FeedbackInteraction::class)->latest();
}
public function attachments(): HasMany
{
return $this->hasMany(FeedbackAttachment::class);
}
public function tags(): BelongsToMany
{
return $this->belongsToMany(FeedbackTag::class, 'feedback_feedback_tag');
}
}