Refactor chat functionality: remove ChatController, enhance MessageSent event with broadcasting capabilities, and update Conversation and Message models for improved relationships. Update API routes for chat operations and adjust CORS settings for broadcasting authentication.

This commit is contained in:
Mekan1206
2026-08-15 16:07:23 +05:00
parent b52b567388
commit ccfffe6173
23 changed files with 425 additions and 198 deletions

View File

@@ -5,12 +5,35 @@ namespace App\Models\Chat;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Message extends Model
{
use HasFactory;
public function user()
/**
* @var array<int, string>
*/
protected $fillable = [
'conversation_id',
'user_id',
'body',
'seen_at',
];
/**
* @var array<string, string>
*/
protected $casts = [
'seen_at' => 'datetime',
];
public function conversation(): BelongsTo
{
return $this->belongsTo(Conversation::class);
}
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}