<?php

namespace Modules\User\Repositories;

use Illuminate\Http\Request;
use Modules\User\Interfaces\StoreModuleRepositoryInterface;
use Modules\User\Models\StoreModule;

class StoreModuleRepository implements StoreModuleRepositoryInterface
{
    public function get(Request $request)
    {
        $query = StoreModule::query();

        if ($request->date_from) {
            $query->whereDate('created_at', '>=', $request->date_from);
        }

        if ($request->date_to) {
            $query->whereDate('created_at', '<=', $request->date_to);
        }


        if ( !is_null($request->status) && $request->status == 0) {
            $query->onlyTrashed();
        }

        if ($request->paginate ?? null) {
            $users= $query->paginate(50);
        }else{
            $users=$query->cursor();
        }

        return $users;
    }
}
