HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/www.shooperm.com/Modules/Seller/Http/Controllers/ProductReviewsController.php
<?php

namespace Modules\Seller\Http\Controllers;

use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Modules\Seller\Services\ProductReviewService;
use Yajra\DataTables\Facades\DataTables;

class ProductReviewsController extends Controller
{
    protected $productReviewService;
    public function __construct(ProductReviewService $productReviewService)
    {
        $this->middleware('maintenance_mode');
        $this->productReviewService = $productReviewService;
    }

    public function index()
    {
        $reviews = $this->productReviewService->getAll();
        return view('seller::product_reviews.index',compact('reviews'));
    }

    public function getData(){
        $review = $this->productReviewService->getAll();
        return DataTables::of($review)
        ->addIndexColumn()
        ->addColumn('rating', function($review){
            return view('seller::product_reviews.components._rating_td',compact('review'));
        })
        ->addColumn('customer_feedback', function($review){
            return view('seller::product_reviews.components._customer_feedback_td',compact('review'));
        })
        ->addColumn('customer_time', function($review){
            return view('seller::product_reviews.components._customer_time_td',compact('review'));
        })
        ->addColumn('reply', function($review){
            return view('seller::product_reviews.components._reply_td',compact('review'));
        })
        ->rawColumns(['rating','customer_feedback','customer_time','reply'])
        ->toJson();
    }

    public function reply(Request $review)
    {
        $review = $this->productReviewService->getById($review->id);
        return view('seller::product_reviews.components.reply',compact('review'));
    }


    public function replyStore(Request $request)
    {
        $request->validate([
            'review' => 'required'
        ]);
        $this->productReviewService->reviewStore($request->except('_token'));

        \LogActivity::successLog('reply store successful.');
        return $this->reloadWithData();
    }
    private function reloadWithData(){

        $reviews = $this->productReviewService->getAll();
        return response()->json([
            'TableData' =>  (string)view('seller::product_reviews.components.list', compact('reviews'))
        ]);
    }

}