<?php


namespace App\Repositories\Eloquent;


use App\Models\User;
use App\Repositories\Contracts\UserRepositoryInterface;
use Illuminate\Http\Request;

class UserRepository implements UserRepositoryInterface
{

    public function all(Request $request)
    {
        if ($request->has('search')) {
            return User::search($request->search)->get();
        }

        return User::with('recruiterProfile', 'researcherProfile', 'studentProfile')->orderBy('id', 'desc')->get();
    }

    public function create(array $properties)
    {
        return User::create($properties);
    }

    public function update($user, array $properties)
    {
        return $user->update($properties);
    }

    public function delete($user)
    {
        return $user->delete();
    }
}
