| 123456789101112131415161718192021222324 |
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\Models\Post;
- use App\Events\CommentPosted;
- class CommentController extends Controller
- {
- //
- public function store(Request $request, Post $post)
- {
- $validated = $request->validate([
- 'author_name' => 'required|string',
- 'body' => 'required|string',
- ]);
- $comment = $post->comments()->create($validated);
- CommentPosted::dispatch($comment);
- return back()->with('success', 'Успешно!');
- }
- }
|