<?php

namespace App\Repositories\Eloquent;

use App\Libs\Consts\ProfessionConst;
use App\Models\Profession;
use App\Repositories\Interfaces\ProfessionRepositoryInterface;
use Illuminate\Support\Collection;

class ProfessionRepository extends BaseRepository implements ProfessionRepositoryInterface
{

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

    public function getParentProfession()
    {
        return $this->model->where('parent_id', ProfessionConst::SET_AS_PARENT)->orderBy('name')->pluck('name', 'id');
    }

    public function removeAsParent($professionId)
    {
        return $this->model->where('parent_id', $professionId)->update(['parent_id' => ProfessionConst::SET_AS_PARENT]);
    }
}
