Add customer contact inquiry system, automated receipt emails, admin communication inbox, and customer profile management
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class Communication extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'order_id',
|
||||
'name',
|
||||
'email',
|
||||
'phone',
|
||||
'subject',
|
||||
'message',
|
||||
'status',
|
||||
'admin_notes',
|
||||
'ip_address',
|
||||
'user_agent',
|
||||
'last_replied_at',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'last_replied_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function order(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Order::class);
|
||||
}
|
||||
|
||||
public function replies(): HasMany
|
||||
{
|
||||
return $this->hasMany(CommunicationReply::class)->oldest();
|
||||
}
|
||||
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
'new' => 'Nieuw',
|
||||
'in_progress' => 'In behandeling',
|
||||
'resolved' => 'Beantwoord',
|
||||
'closed' => 'Gesloten',
|
||||
default => ucfirst($this->status),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class CommunicationReply extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'communication_id',
|
||||
'user_id',
|
||||
'is_admin_reply',
|
||||
'message',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'is_admin_reply' => 'boolean',
|
||||
];
|
||||
|
||||
public function communication(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Communication::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
}
|
||||
@@ -48,4 +48,14 @@ class User extends Authenticatable
|
||||
{
|
||||
return $this->hasMany(Order::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Communications / questions submitted by this user.
|
||||
*
|
||||
* @return HasMany<Communication, $this>
|
||||
*/
|
||||
public function communications(): HasMany
|
||||
{
|
||||
return $this->hasMany(Communication::class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user