Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/mcoil.corals.io/app/Http/Controllers/Admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/app/Http/Controllers/Admin/DashboardController.php
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Shop\DiscountCoupons\DiscountCoupon;
use App\Shop\Customers\Customer;
use App\Shop\Customers\Repositories\CustomerRepository;
use App\Shop\Customers\Repositories\Interfaces\CustomerRepositoryInterface;
use App\Shop\Customers\Transformations\CustomerTransformable;
use App\Shop\ContactInfos\ContactInfo;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
class DashboardController extends Controller {
	use CustomerTransformable;

    /**
     * @var CustomerRepositoryInterface
     */
    private $customerRepo;

    /**
     * CustomerController constructor.
     * @param CustomerRepositoryInterface $customerRepository
     */
    public function __construct(CustomerRepositoryInterface $customerRepository) {
        $this->customerRepo = $customerRepository;
    }

    public function index() {
    	$todayDate = date('Y-m-d');
    	$discount_coupons = DiscountCoupon::where('status', '1')->whereDate('valid_upto', '>', $todayDate)->take(21)->get();
    	/*$list = $this->customerRepo->listCustomers('created_at', 'desc');
    	$customers = $list->map(function (Customer $customer) {
    	    return $this->transformCustomer($customer);
    	})->all();*/
    	//$customers = $this->customerRepo->paginateArrayResults($customers);
    	$todaysDeliveries = DB::table('orders as t1')
    		->join('order_product as t2', 't1.id', '=', 't2.order_id')
			->join('products as t3', 't2.product_id', '=', 't3.id')
    		->join('order_statuses as t4', 't1.order_status_id', '=', 't4.id')
    		->join('addresses as t5', 't5.id', '=', 't1.address_id')
    		->leftJoin('customers', 'customers.id','=','t1.driver_id')
    		->where('t1.oil_type_order', '=', '1')
    		->select('t1.id', 't1.delivery_date', 't3.name as product_name', 't4.name as status', 't5.address_1', 't5.address_2', 't5.county', 't5.town', 't5.zip','customers.id as driver_id','customers.name as driver_name','t3.cover as cover')
            ->where(function($query) use ($todayDate){
                $query->where(function($query) use ($todayDate){
                    $query->whereIn('t4.name', ['pending', 'awaiting payment']);
                    $query->whereDate('t1.delivery_date', '<=', $todayDate);
                });
                $query->orWhere(function($query) use ($todayDate){
                    $query->whereIn('t4.name', ['paid']);
                    $query->whereDate('t1.delivery_date', '=', $todayDate);
                });
             })
    		/*->whereIn('t4.name', ['paid', 'pending', 'awaiting payment'])
    		->whereDate('t1.delivery_date', '<=', $todayDate)*/
    		->orderBy('id', 'DESC')
    		->get();
    	$latestOilOrders = DB::table('orders as t1')
    	    ->join('order_product as t2', 't1.id', '=', 't2.order_id')
    		->join('products as t3', 't2.product_id', '=', 't3.id')
    		->join('order_statuses as t4', 't1.order_status_id', '=', 't4.id')
    		->where('t1.oil_type_order', '=', '1')
    		//->where('t4.name', '=', 'pending')
    		->whereIn('t4.name', ['pending', 'awaiting payment'])
    		->select('t1.id', 't3.name as product_name', 't4.name as status','t3.cover as cover')->get();
    		//->paginate(21);
    	$latestProductOrders = DB::table('orders as t1')
    		->join('order_product as t2', 't1.id', '=', 't2.order_id')
    		->join('products as t3', 't2.product_id', '=', 't3.id')
    		->join('order_statuses as t4', 't1.order_status_id', '=', 't4.id')
    		->groupBy('t2.product_id')
    		->where('t1.oil_type_order', '=', '0')
			->select('t1.id', 't4.name as status', DB::raw('group_concat(t3.name) as product_name'))->get();
    		//->paginate(21);
    	$latestProductOrderPendingCount = DB::table('orders as t1')
			->join('order_product as t2', 't1.id', '=', 't2.order_id')
			->join('products as t3', 't2.product_id', '=', 't3.id')
			->join('order_statuses as t4', 't1.order_status_id', '=', 't4.id')
			->groupBy('t2.product_id')
			->where('t1.oil_type_order', '=', '0')
			->where('t4.name', '=', 'pending')
			->count();

        $todaysCustomerCount = Customer::select("customers.*")
            ->whereNull('deleted_at')
            ->where('is_driver', '=', '0')
            //->leftJoin('orders','orders.customer_id','=','customers.id')
            ->whereDate('created_at', '=', $todayDate)
            ->count();

        //$todaysCustomerCount = Customer::whereDate('created_at', '=', $todayDate)->count();
		$todayDiscountCouponCount = DiscountCoupon::where('status', '1')->whereDate('created_at', '=', $todayDate)->count();
		$contactInfo = ContactInfo::find(2);
        return view('admin.dashboard', [
        	'discount_coupons' => $discount_coupons, 
        	'todaysDeliveries' => $todaysDeliveries,
        	'latestOilOrders' => $latestOilOrders,
        	'latestProductOrders' => $latestProductOrders,
        	'latestProductOrderPendingCount' => $latestProductOrderPendingCount,
        	'todaysCustomerCount' => $todaysCustomerCount,
        	'todayDiscountCouponCount' => $todayDiscountCouponCount,
        	'contactInfo' => $contactInfo
        ]);
    }

    public function latestCustomersServerPagination(Request $request)
    {
        $columns = array(
            0 => 'id',
            1 => 'name',
            2 => 'status',
            3 => 'actions',
        );

        $list = Customer::query()
            ->whereNull('deleted_at')
            ->where('is_driver', '=', '0');

        $totalData = $list->count();
        $totalFiltered = $totalData;

        if (!empty($request->input('search.value'))) {
            $search = $request->input('search.value');

            $list = $list->where(function ($query) use ($search) {
                $query->Where('id', 'LIKE', '%' . $search . '%')
                    ->orWhere('name', 'LIKE', '%' . $search . '%')
                    ->orWhere('status', 'LIKE', '%' . $search . '%');
            });
            $totalFiltered = $list->count();
        }

        $start = $request->input('start');
        $limit = $request->input('length');
        $order = $columns[$request->input('order.0.column')];
        $dir = $request->input('order.0.dir');
        $data = [];

        if ($order == 'actions'){
            $order = 'id';
        }
        if ($limit == '-1'){
            $list = $list->orderBy($order, $dir)->get();
        }else{
            $list = $list->offset($start)->limit($limit)->orderBy($order, $dir)->get();
        }

        if (count($list) > 0) {
            foreach ($list as $customer) {
                $nestedData['id'] = $customer->id;
                $nestedData['name'] = $customer->name;
                $nestedData['status'] = "<span class='badge font-badge " . ($customer->status != '1' ? 'badge-danger' : 'badge-success') . "'> " . ($customer->status != '1' ? 'disabled' : 'enabled') . "</span>";
                $nestedData['actions'] = "<a href='" . route('admin.customers.show', $customer['id']) . "' class='btn btn-default'><i class='fa fa-eye'></i> View</a>";

                $data[] = $nestedData;
            }
        }
        $json_data = array(
            "draw" => intval($request->input('draw')),
            "recordsTotal" => intval($totalData),
            "recordsFiltered" => intval($totalFiltered),
            "data" => $data
        );

        echo json_encode($json_data);
    }

    public function message(){
     $message = DB::table('messages')->first();
 
     return view('admin.message',['message'=>$message]);   
    }

     public function saveMessage(Request $request){
       DB::table('messages')->where('id',$request->input('message_id'))->update(['description'=>$request->input('description'), 'message'=>$request->input('message')]);
       return redirect()->route('admin.messages.index')->with('message', 'Message Updated successfully!');
    }
}

Spamworldpro Mini