<?php

namespace App\Repositories;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\CategoryRepository;
use App\Models\Category;
use App\Validators\CategoryValidator;

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

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

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

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

    }

    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 getAllCategories()
    {
        return parent::all();
    }

    public function getBySlug($slug)
    {
        return parent::findWhere(['slug' => $slug])->first();
    }
    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }

}
