<?php

namespace Webkul\Admin\Http\Controllers\Reporting;

use Illuminate\View\View;

class ProductController extends Controller
{
    /**
     * Request param functions.
     *
     * @var array
     */
    protected $typeFunctions = [
        'total-sold-quantities' => 'getTotalSoldQuantitiesStats',
        'total-products-added-to-wishlist' => 'getTotalProductsAddedToWishlistStats',
        'top-selling-products-by-revenue' => 'getTopSellingProductsByRevenue',
        'top-selling-products-by-quantity' => 'getTopSellingProductsByQuantity',
        'products-with-most-reviews' => 'getProductsWithMostReviews',
        'products-with-most-visits' => 'getProductsWithMostVisits',
        'last-search-terms' => 'getLastSearchTerms',
        'top-search-terms' => 'getTopSearchTerms',
    ];

    /**
     * Display a listing of the resource.
     *
     * @return View
     */
    public function index()
    {
        return view('admin::reporting.products.index')->with([
            'startDate' => $this->reportingHelper->getStartDate(),
            'endDate' => $this->reportingHelper->getEndDate(),
        ]);
    }

    /**
     * Display a listing of the resource.
     *
     * @return View
     */
    public function view()
    {
        if ($this->validateRequestedType()) {
            abort(404);
        }

        return view('admin::reporting.view')->with([
            'entity' => 'products',
            'startDate' => $this->reportingHelper->getStartDate(),
            'endDate' => $this->reportingHelper->getEndDate(),
        ]);
    }
}
