progress
This commit is contained in:
@@ -3,9 +3,55 @@
|
||||
namespace App\Http\Controllers\Forum;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Forum\PostRequest;
|
||||
use App\Models\Forum\Post;
|
||||
use App\Models\Forum\Thread;
|
||||
use App\Models\Forum\Topic;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PostsController extends Controller
|
||||
{
|
||||
//
|
||||
public function create()
|
||||
{
|
||||
// full reply?
|
||||
}
|
||||
|
||||
public function store(PostRequest $request, string $categorySlug, string $threadSlug, string $topicSlug)
|
||||
{
|
||||
$thread = Thread::with('category')->where('slug', $threadSlug)->first();
|
||||
$topic = Topic::where('slug', $topicSlug)->first();
|
||||
|
||||
if ($topic->status == Topic::STATUS_CLOSED) {
|
||||
abort(403);
|
||||
}
|
||||
|
||||
Post::create([
|
||||
'content' => $request->get('content'),
|
||||
'user_id' => auth()->user()->id,
|
||||
'category_id' => $thread->category->id,
|
||||
'thread_id' => $thread->id,
|
||||
'topic_id' => $topic->id,
|
||||
]);
|
||||
|
||||
$topic->replies_no = $topic->replies_no+1;
|
||||
$topic->save();
|
||||
|
||||
// redirect back, keep in mind pagination
|
||||
return redirect()->back()->with('success', 'Reply posted!');
|
||||
}
|
||||
|
||||
public function edit(int $id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function update(PostRequest $request, int $id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function destroy(int $id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user