<?php

namespace Modules\PaymentLog\Controllers\Canteen;

/** Ajax Request */

use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Modules\Canteen\Services\CanteenService;
use Modules\PaymentLog\Enums\PaymentLogAccStatusEnum;
use Modules\PaymentLog\Enums\PaymentLogStatusEnum;
use Modules\PaymentLog\Services\PaymentLogService;
use Modules\User\Services\UserService;

class PaymentLogController extends Controller
{

    /** Redirect to this path after each operation success*/
    private $redirectSuccessPath= '/canteen/payment_logs';
    /** View folder */
    private $viewDirectory= 'canteen.payment_logs.';
    //

    public function __construct(
        private PaymentLogService $paymentLogService,
        private CanteenService $canteenService,
    ){}

    /**
     * Display a listing of the payment_logs.
     *
     * @param Request $request
     * @return View
     */
    public function index(Request $request) :View
    {
        $title = __('payment_logs.head');
        $acc_statuses = PaymentLogAccStatusEnum::values();
        $statuses = PaymentLogStatusEnum::operations();
        return view($this->viewDirectory.'index', get_defined_vars());
    }

    /**
     * return data of the payment_logs.
     *
     * @param Request $request
     * @return View
     */
    public function grid(Request $request) :View
    {
        $request->merge(
            [
                'paginate'=>true,
                'canteen_id'=>auth()->user()->canteen_id,
                'acc_status'=>PaymentLogAccStatusEnum::CANTEEN->value
            ]);
        $payment_logs = $this->paymentLogService->get($request->all());

        return view($this->viewDirectory.'grid',get_defined_vars());
    }

}
