Files
minicrm/app/Models/Feedback.php
phuongtc 887765bbd7 feat: AfterSales CRM - SOP compliant real-estate customer care system
- Departments + cross-department transfer workflow
- Role-based closing (staff→resolved, manager→closed) with proof_of_resolution
- Private file storage with collection system + temporary signed URLs
- Dashboard: resolved tickets table, stats, handler performance bar chart
- Spatie RBAC (admin/manager/staff)
- Notifications: TicketTransferred, TicketClosed (database + mail)
- Pest tests: 8 tests, 21 assertions
- Docker production-ready (Dockerfile + compose + entrypoint)
2026-04-27 05:29:48 +00:00

59 lines
1.6 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', '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 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');
}
}