<?php

namespace App\Repositories\Eloquent;

use App\Models\UserProfile;
use App\Repositories\Interfaces\UserProfileRepositoryInterface;
use Illuminate\Support\Collection;

class UserProfileRepository extends BaseRepository implements UserProfileRepositoryInterface
{

    /**
    * UserProfileRepository constructor.
    *
    * @param UserProfile $model
    */
    public function __construct(UserProfile $model)
    {
       parent::__construct($model);
    }

    public function ordering($field, $order, $userProfiles)
    {
        $sorting = $order == 'asc' ? 'sortBy' : 'sortByDesc';

        return $userProfiles->$sorting($field);
    }

    public function getByUser($userId)
    {
        return $this->model->where('user_id', $userId)->first();
    }
}
