<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

/**
 * Class CompanyEmployee
 * @package App\Models
 *
 * @property \App\Models\Company company_id
 * @property \App\Models\User user_id
 */
class Employee extends AbstractModel
{
    protected $table = 'employees';

    /**
     * @return HasMany
     */
    public function company(): HasMany
    {
        return $this->HasMany(Company::class, 'company_id', 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     **/
    public function user(): HasOne
    {
        return $this->hasOne(User::class, 'user_id', 'id');
    }

    /**
     * @return belongsToMany
     */
    public function milestones()
    {
        return  $this->belongsToMany(Milestone::class, 'milestone_progress', 'user_id', 'milestone_id')
                ->withPivot('created_at');
    }
}
