<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Vente extends Model
{
    use HasFactory;

    public $fillable = [
        'prix',
        'honoraires',
        'num_mandat',
        'type_mandat',
        'date_mandat',
        'passe_sous_compromis',
        'charges_honoraires',
        'copro_quote_part',
        'copro_nombre_lots',
        'copro_proc_dilig',
        'copropriete',
        'bien_id',
        'signature',
        'wysiwyg'
    ];

    public function bien(){
        return $this->belongsTo(Bien::class);
    }

    public function typeMandat(){
        switch($this->type_mandat) {
            case 'S':
                return 'simple';
                break;
            case 'E':
                return 'exclusif';
                break;
            case 'P':
                return 'privilégié';
                break;
        } 
    }
}
