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:
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use BasementChat\Basement\Enums\MessageType;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('private_messages', static function (Blueprint $table): void {
|
||||
/** @var string $model */
|
||||
$model = config('basement.user_model');
|
||||
/** @var Model $user */
|
||||
$user = app($model);
|
||||
|
||||
$primaryKey = $user->getKeyName();
|
||||
$tableName = $user->getTable();
|
||||
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('receiver_id');
|
||||
$table->unsignedBigInteger('sender_id');
|
||||
$table->foreign('receiver_id')->references($primaryKey)->on($tableName);
|
||||
$table->foreign('sender_id')->references($primaryKey)->on($tableName);
|
||||
$table->enum('type', [MessageType::document()->value, MessageType::text()->value]);
|
||||
$table->string('value');
|
||||
$table->timestamp('read_at')->nullable();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('private_messages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::dropIfExists('private_messages');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Basement Chat leftovers are not restored.
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user