%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/workeasy-api/app/Models/
Upload File :
Create Path :
Current File : /var/www/html/workeasy-api/app/Models/Candidate.php

<?php

namespace Workeasy\Models;


class Candidate extends BaseModel
{

    protected $fillable = [
        'name',
        'surname',
        'age',
        'description',
        'phone_number',
    ];
    protected $guarded  = ['user_id'];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function offers()
    {
        return $this->belongsToMany(Offer::class, 'interviews');
    }

    public function experiences()
    {
        return $this->hasMany(Experience::class);
    }

    public function interviews()
    {
        return $this->hasMany(Interview::class);
    }

    public function getRating()
    {
        $feedback = Feedback::query()->whereHas('interview', function ($query) {
            $query->where('candidate_id', $this->id);
        });
        $count = $feedback->count() > 0
            ?: 1;
        return $feedback->sum('rating') / $count;
    }

}

Zerion Mini Shell 1.0