<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class FaqController extends Controller
{
    public function index(Request $request)
    {
        $perPageItems = 999;
        $page = $request->get("p");
        $page = (!$page || $page < 1) ? 1 : $page;
        $pageOffset = $perPageItems * ($page - 1);

        $dataRows = \App\Models\Faq::where('is_front_show', '=', true)
            ->orderBy('post_at', 'desc');
            //->select('id', 'title', 'description', 'body', 'photos', 'post_at');

        return view('faqs', [
            'dataRows' => $dataRows->skip($pageOffset)->take($perPageItems)->get(),
            'dataCurrentPage' => $page,
            'dataPerPageItems' => $perPageItems,
            'dataTotalCount' => $dataRows->count(),
        ]);
    }

}
