<?php

namespace App\Repositories\User;

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

class KontrakKerjaRepository extends Repository
{
    protected $model;

    public function __construct(KontrakKerja $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);
    }
}
