<?php

namespace Modules\DailyLog\Repositories;

use Illuminate\Http\Request;
use Mcamara\LaravelLocalization\Facades\LaravelLocalization;
use Modules\DailyLog\Interfaces\DailyLogRepositoryInterface;
use Modules\DailyLog\Models\DailyLog;

class DailyLogRepository implements DailyLogRepositoryInterface
{
    public function get(array $request)
    {
        return DailyLog::query();
    }

    public function getItem(int $id)
    {
        return DailyLog::find($id);
    }


    public function checkItem(int $id)
    {
        return DailyLog::find($id);
    }

    public function getItemTrashed(int $id)
    {
        $dailyLog = DailyLog::onlyTrashed()->find($id);
        return $dailyLog ;
    }

    public function create(array $request): DailyLog
    {
        $dailyLog = DailyLog::create($request);
        return $dailyLog;
    }

    public function update(array $request, ?DailyLog $dailyLog): DailyLog
    {
        $dailyLog->update($request);

        return $dailyLog;
    }

    /**
     * Remove the specified category from storage.
     * @param DailyLog $dailyLog
     * @return void
     */
    public function destroy(DailyLog $dailyLog) :void
    {
        $dailyLog->delete();
    }

    /**
     * Remove several categories by IDs.
     *
     * @param array $request
     * @return void
     */
    public function destroyAll(array $ids) :void
    {
        DailyLog::whereIn('id', $ids)->delete();
    }

    /**
     * Restore the specified category from storage.
     *
     * @param DailyLog $dailyLog
     * @return void
     */
    public function restore(DailyLog $dailyLog) :void
    {
        $dailyLog->restore();
    }

    /**
     * Restore several categories by IDs.
     *
     * @param array $request
     * @return void
     */
    public function restoreAll(array $ids) :void
    {
        DailyLog::whereIn('id', $ids)->onlyTrashed()->restore();
    }
}
