Server IP : 162.213.251.212 / Your IP : 18.222.106.87 [ Web Server : LiteSpeed System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : allssztx ( 535) PHP Version : 8.1.31 Disable Function : NONE Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/home/allssztx/public_html/easybuyer/app/Http/Controllers/ |
Upload File : |
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Response; use Illuminate\Support\Str; use App\Models\Comment; use App\Models\CommentReplay; use App\Models\Post; use Auth; class CommentController extends Controller { // public function insert_comment(Request $req) { if(auth()->check()) { $id = $req->postId; $post = Post::find($id); if(!$post) { return response()->json(['posterror'=>'Post Not Found!']); } $validation = Validator::make($req->all(),[ 'Comment' => 'required|max:3000', ],[ 'Comment.required' => 'Please Enter Comment Text', 'Comment.max' => 'Comment Max Length Is 3000', ]); if(!$validation->passes()) { return response()->json(['error'=>$validation->errors()]); } else { $AddComment = new Comment; $AddComment->post_id = $id; $AddComment->user_id = Auth::user()->id; $AddComment->comment = $req->Comment; $AddComment->save(); return response()->json(['success'=>'Comment Add Successfully']); } } else { return response()->json(['loginerror'=>'Please Login First']); } } public function reply_comment(Request $req) { if(auth()->check()) { $id = $req->commentId; $comment = Comment::find($id); if(!$comment) { return response()->json(['commenterror'=>'Comment Not Found!']); } $validation = Validator::make($req->all(),[ 'reply' => 'required|max:3000', ],[ 'reply.required' => 'Please Enter Comment Text', 'reply.max' => 'Comment Max Length Is 3000', ]); if(!$validation->passes()) { return response()->json(['error'=>$validation->errors()]); } else { $AddReply = new CommentReplay; $AddReply->comment_id = $req->commentId; $AddReply->user_id = Auth::user()->id; $AddReply->comment = $req->reply; $AddReply->save(); return response()->json(['success'=>'Replay Add Successfully']); } } else { return response()->json(['loginerror'=>'Please Login First']); } } }