Uname: Linux peekpos.com 6.8.0-1060-aws #63~22.04.1-Ubuntu SMP Tue Jun 30 02:32:53 UTC 2026 x86_64
Software: Apache
PHP version: 8.3.25 [ PHP INFO ] PHP os: Linux
Server Ip: 47.130.192.226
Your Ip: 10.3.134.78
User: www (1001) | Group: www (1001)
Safe Mode: OFF
Disable Function:
passthru,putenv,chroot,chgrp,chown,shell_exec,popen,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,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

name : RattingController.php
<?php

namespace App\Http\Controllers\addons\included;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Ratting;
use App\Helpers\helper;
use Illuminate\Support\Facades\Validator;

class RattingController extends Controller
{
    public function index()
    {
        $getreview = Ratting::with('user_info')->where('user_id', null)->where('item_id', null)->orderBy('reorder_id')->get();
        return view('admin.included.reviews.reviews', compact('getreview'));
    }
    public function add()
    {
        return view('admin.included.reviews.add');
    }
    public function edit(Request $request)
    {
        $edittestimonial = Ratting::where('id', $request->id)->first();
        return view('admin.included.reviews.edit', compact('edittestimonial'));
    }
    public function save(Request $request)
    {
        $testimonial = new Ratting();
        $testimonial->name = $request->name;

        $testimonial->position = $request->position;

        $testimonial->description = $request->description;

        $testimonial->star = $request->rating;

        if ($request->has('image')) {

            $validator = Validator::make($request->all(), [

                'image' => 'image|max:' . helper::imagesize() . '|' . helper::imageext(),

            ], [

                'image.max' => trans('messages.image_size_message'),

            ]);

            if ($validator->fails()) {

                return redirect()->back()->with('error', trans('messages.image_size_message') . ' ' . helper::appdata('')->image_size . ' ' . 'MB');
            }

            $testimonialimage = 'testimonial-' . uniqid() . "." . $request->file('image')->getClientOriginalExtension();

            $request->file('image')->move(storage_path('app/public/admin-assets/images/testimonials/'), $testimonialimage);

            $testimonial->image = $testimonialimage;
        }

        $testimonial->save();
        return redirect('admin/reviews')->with('success', trans('messages.success'));
    }

    public function update(Request $request)
    {
        $edittestimonial = Ratting::where('id', $request->id)->first();

        $edittestimonial->name = $request->name;

        $edittestimonial->position = $request->position;

        $edittestimonial->star = $request->rating;

        $edittestimonial->description = $request->description;

        if ($request->has('image')) {

            $validator = Validator::make($request->all(), [

                'image' => 'image|max:' . helper::imagesize() . '|' . helper::imageext(),

            ], [

                'image.max' => trans('messages.image_size_message'),

            ]);

            if ($validator->fails()) {

                return redirect()->back()->with('error', trans('messages.image_size_message') . ' ' . helper::appdata('')->image_size . ' ' . 'MB');
            }

            if (file_exists(storage_path('app/public/admin-assets/images/testimonials/' . $edittestimonial->image))) {

                unlink(storage_path('app/public/admin-assets/images/testimonials/' . $edittestimonial->image));
            }

            $testimonialimage = 'testimonial-' . uniqid() . "." . $request->file('image')->getClientOriginalExtension();

            $request->file('image')->move(storage_path('app/public/admin-assets/images/testimonials/'), $testimonialimage);

            $edittestimonial->image = $testimonialimage;
        }

        $edittestimonial->update();
        return redirect('admin/reviews')->with('success', trans('messages.success'));
    }
    public function destroy(Request $request)
    {

        try {
            $review = Ratting::where('id', $request->id)->delete();
            if ($review) {
                return 1;
            } else {
                return 0;
            }
        } catch (\Throwable $th) {
            return 0;
        }
    }
    public function reorder_testimonials(Request $request)
    {

        $gettestimonial = Ratting::get();
        foreach ($gettestimonial as $testimonial) {
            foreach ($request->order as $order) {
                $testimonial = Ratting::where('id', $order['id'])->first();
                $testimonial->reorder_id = $order['position'];
                $testimonial->save();
            }
        }
        return response()->json(['status' => 1, 'msg' => trans('messages.success')], 200);
    }
}
© 2026 GrazzMean