Implement Authentication States, show logout options in auth store and services. Make DB and controllers to make messages grouped by chats. Refactor backend code to use DTO.
19 lines
395 B
PHP
19 lines
395 B
PHP
<?php
|
|
|
|
namespace App\Actions\Chats;
|
|
|
|
use App\Enums\Chats\ChatRoles;
|
|
use App\Models\Chat;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
final readonly class StoreChatMessageAction
|
|
{
|
|
public function store(Chat $chat, ChatRoles $role, string $message): Model
|
|
{
|
|
return $chat->messages()->create([
|
|
'role' => $role->value,
|
|
'content' => $message,
|
|
]);
|
|
}
|
|
}
|