<?php

namespace Modules\User\Repositories;

use App\Models\UserModule;
use Illuminate\Http\Request;
use Modules\User\Interfaces\CanteenModuleRepositoryInterface;
use Modules\User\Interfaces\ModuleRepositoryInterface;
use Modules\User\Models\CanteenModule;
use Modules\User\Models\Module;
use Modules\User\Models\UserCanteenModule;

class CanteenModuleRepository implements CanteenModuleRepositoryInterface
{
    public function get(array $request)
    {
        return CanteenModule::query();
    }

    public function getItemByPath(string $path)
    {
        return CanteenModule::where('name',$path)->first();
    }

    public function checkModuleAccess(int $module_id , int $user_id)
    {
        return UserCanteenModule::query()
            ->where('canteen_module_id',$module_id)
            ->where('user_id',$user_id)
            ->first();
    }
}
