- Updated `Chat` and `ChatMessage` models for new table structures with UUIDs and attributes. - Integrated `ChatPolicy` for authorization checks. - Updated `ChatMessageController` with authorization and refined logic. - Adjusted routes and state in the frontend to handle chat IDs from the URL. - Enhanced `SocialMediaService` for handling chat-specific user prompts. - Removed unused migrations related to chats and chat messages.
23 lines
639 B
PHP
23 lines
639 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Http\Requests\GeneratePostRequest;
|
|
use App\Http\Resources\GeneratedPostResource;
|
|
use App\Models\Chat;
|
|
use App\Services\SocialMediaService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Attributes\Controllers\Authorize;
|
|
|
|
class ChatMessageController extends Controller
|
|
{
|
|
#[Authorize('update', 'chat')]
|
|
public function store(GeneratePostRequest $request, Chat $chat, SocialMediaService $socialMediaService)
|
|
{
|
|
return new GeneratedPostResource(
|
|
$socialMediaService
|
|
->generatePostWithImage($request->input('prompt'), $chat)
|
|
);
|
|
}
|
|
}
|