Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
682da3dea8 |
@@ -71,6 +71,9 @@ class MutationController extends Controller
|
|||||||
return $mutation;
|
return $mutation;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Broadcast the real-time creation event!
|
||||||
|
broadcast(new MutationCreated($mutation));
|
||||||
|
|
||||||
return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]);
|
return redirect()->route('dynamics.ledgers.show', [$dynamic, $ledger]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +149,9 @@ class MutationController extends Controller
|
|||||||
}
|
}
|
||||||
broadcast(new MessageSent($dynamicMsg));
|
broadcast(new MessageSent($dynamicMsg));
|
||||||
|
|
||||||
|
// Broadcast the real-time update event!
|
||||||
|
broadcast(new MutationUpdated($mutation));
|
||||||
|
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,15 +92,6 @@ class Mutation extends Model
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
broadcast(new MessageSent($dynamicMsg));
|
broadcast(new MessageSent($dynamicMsg));
|
||||||
|
|
||||||
// Trigger the real-time creation broadcast dynamically
|
|
||||||
broadcast(new \App\Events\MutationCreated($mutation));
|
|
||||||
});
|
|
||||||
|
|
||||||
static::updated(function (Mutation $mutation) {
|
|
||||||
if ($mutation->wasChanged('status')) {
|
|
||||||
broadcast(new \App\Events\MutationUpdated($mutation));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Carbon\CarbonImmutable;
|
use Carbon\CarbonImmutable;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\Relation;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
use Illuminate\Support\Facades\Date;
|
use Illuminate\Support\Facades\Date;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -26,6 +27,13 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
JsonResource::withoutWrapping();
|
JsonResource::withoutWrapping();
|
||||||
$this->configureDefaults();
|
$this->configureDefaults();
|
||||||
|
|
||||||
|
Relation::morphMap([
|
||||||
|
'user' => \App\Models\User::class,
|
||||||
|
'dynamic' => \App\Models\Dynamic::class,
|
||||||
|
'ledger' => \App\Models\Ledger::class,
|
||||||
|
'mutation' => \App\Models\Mutation::class,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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::table('messages', function (Blueprint $table) {
|
||||||
|
DB::table('messages')->where('subject_type', 'App\\Models\\User')->update(['subject_type' => 'user']);
|
||||||
|
DB::table('messages')->where('subject_type', 'App\\Models\\Mutation')->update(['subject_type' => 'mutation']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('messages', function (Blueprint $table) {
|
||||||
|
DB::table('messages')->where('subject_type', 'user')->update(['subject_type' => 'App\\Models\\User']);
|
||||||
|
DB::table('messages')->where('subject_type', 'mutation')->update(['subject_type' => 'App\\Models\\Mutation']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -202,16 +202,16 @@ function parseMessageContent(message: {
|
|||||||
// 2. Link subjects if found in the text
|
// 2. Link subjects if found in the text
|
||||||
if (message.subject_id && message.subject_type) {
|
if (message.subject_id && message.subject_type) {
|
||||||
if (
|
if (
|
||||||
message.subject_type === 'App\\Models\\Mutation' ||
|
message.subject_type === 'mutation' ||
|
||||||
message.subject_type === 'App\\Models\\Ledger'
|
message.subject_type === 'ledger'
|
||||||
) {
|
) {
|
||||||
const ledgerId =
|
const ledgerId =
|
||||||
message.subject_type === 'App\\Models\\Mutation'
|
message.subject_type === 'mutation'
|
||||||
? message.subject?.ledger_id
|
? message.subject?.ledger_id
|
||||||
: message.subject?.id;
|
: message.subject?.id;
|
||||||
|
|
||||||
const ledgerName =
|
const ledgerName =
|
||||||
message.subject_type === 'App\\Models\\Mutation'
|
message.subject_type === 'mutation'
|
||||||
? message.subject?.ledger?.name
|
? message.subject?.ledger?.name
|
||||||
: message.subject?.name;
|
: message.subject?.name;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user