<?php

namespace App\Models;

use App\Services\Upload\FileService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * @property mixed id
 */
class Demand extends Model
{
    //use soft delete
    use SoftDeletes;

    protected $fillable = [
        'first_name','last_name','email','phone','nationality_id','cv'
    ];

    public function setCvAttribute($value)
    {
        $image = FileService::uploadFile($value);
        $this->attributes['cv'] = $image;
    }

    public function getNameAttribute()
    {
        return $this->first_name .' '. $this->last_name;
    }
    public function nationality()
    {
        return $this->belongsTo(Nationality::class)->withTrashed();
    }

}
