<?php

namespace App\Repositories\User;

use App\Models\User\Fasilitas;
use App\Repositories\Repository;

class FasilitasRepository extends Repository
{
    protected $model;

    public function __construct(Fasilitas $model)
    {
        $this->model = $model;
    }

    public function get($with = null, $search = null, $id = null)
    {
        return $this->model->when($with, function ($query) use ($with) {
            return $query->with($with);
        })
            ->when($search, function ($query) use ($search) {
                return $query->where('search', $search);
            })
            ->when($id, function ($query) use ($id) {
                return $query->where('id', $id);
            })
            ->get();
    }

    public function paginate($with = null, $limit = 10, $idlogkeg = null)
    {
        return Rekognisi::when($with, function ($query) use ($with) {
            return $query->with($with);
        })
            ->when($tahun, function ($query) use ($tahun) {
                return $query->where('tahun', $tahun);
            })
            ->when($id_kegiatan, function ($query) use ($id_kegiatan) {
                return $query->where('id_kegiatan', $id_kegiatan);
            })
            ->paginate($limit);
    }
}
