<?php

namespace App\Repositories\Eloquent;

use App\Models\Profile;
use App\Repositories\Interfaces\ProfileRepositoryInterface;
use Illuminate\Support\Collection;

class ProfileRepository extends BaseRepository implements ProfileRepositoryInterface
{

    /**
    * ProfileRepository constructor.
    *
    * @param Profile $model
    */
    public function __construct(Profile $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();
    }
}
