<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MeritIncreaseMatrix extends Model
{
    protected $fillable = [
        'organisation_id',
        'job_grade_id',
        'performance_tercile',
        'pos_min',
        'pos_max',

        'outstanding_min',
        'outstanding_target',
        'outstanding_max',
        'exceeded_min',
        'exceeded_target',
        'exceeded_max',
        'achieved_min',
        'achieved_target',
        'achieved_max',
        'partially_met_min',
        'partially_met_target',
        'partially_met_max',
        'below_min',
        'below_target',
        'below_max',
    ];

    protected static function booted()
    {
        static::creating(function ($model) {
            if (auth()->check()) {
                $model->organisation_id = auth()->user()->organisation_id;
            }
        });
    }

    public function jobGrade()
    {
        return $this->belongsTo(JobGrade::class);
    }

    public function organization()
    {
        return $this->belongsTo(Organisation::class);
    }
}
