<?php

namespace App\Repositories;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\FaqRepository;
use App\Models\Faq;
use App\Validators\FaqValidator;

/**
 * Class FaqRepositoryEloquent.
 *
 * @package namespace App\Repositories;
 */
class FaqRepositoryEloquent extends BaseRepository implements FaqRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return Faq::class;
    }

    public function indexPage()
    {
        $get_faqs = parent::all();
        return view('admin.faq.index', compact('get_faqs'));
    }

    public function createPage()
    {
        return view('admin.faq.add');

    }
    public function editPage($id)
    {
        $find_faq = parent::find($id);
        return view('admin.faq.update', compact('find_faq'));

    }

    public function create($data)
    {
        return parent::create($data);
    }
    public function update($data, $id)
    {
        return parent::update($data, $id);

    }

    public function delete($id)
    {
        return parent::delete($id);
    }

    public function getById($id)
    {
        return parent::find($id);
    }


    public function getAllfaqs()
    {
        return parent::all();
    }

    public function indexView()
    {
        return parent::orderBy('created_at', 'desc')->take(3)->get();
    }

    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
    
}
