<?php

namespace App\Http\Controllers\Web;

use App\Bank;
use App\Helpers\ImageHelper;
use App\Page;
use App\Slider;
use App\Product;
use App\Article;
use App\Supplier;
use App\Testimonial;
use App\PhotoGallery;
use Illuminate\Http\Request;
use Illuminate\View\View;
use App\Http\Controllers\Controller;


class HomeController extends Controller
{
    private $view = 'web.';

    /**
     * Show the application dashboard.
     * @return View
     */
    public function index(): View
    {
        $title = __('main.home');
        $sliders = Slider::withDescription(); //
        $pages = Page::withDescription();
        $homeProducts = Product::withDescription([], 8);
        $suppliers = Supplier::withDescription();
        $testimonials = Testimonial::withDescription();
        $banks = Bank::select(['image', 'url'])->cursor();
        $articles = Article::withDescription(null, 3);
        $galleries = PhotoGallery::withDescription();
        
        return view($this->view.'home', get_defined_vars());
    }

    public function testUpload(Request $request)
    {
        if (!$request->test_file){
            return back()->with('errors', 'Choose A (PDF) File Pro');
        }
        $file = ImageHelper::upload($request->test_file, 'test_file_upload');
        dd('File uploaded success in path: ' . $file);
    }
}
