<?php

namespace App\Models;

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

class ClientMemo extends Model
{
    protected $table = 'client_memo';

    public function createdBy(): HasOne
    {
        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
    }

    public function client(): HasOne
    {
        return $this->hasOne(Client::class, 'id', 'client_id');
    }

    public function updates(): HasMany{
        return $this->hasMany(ClientMemoUpdate::class, 'client_memo_id', 'id')->orderBy('created_at', 'DESC');
    }

    public function stamp(): HasOne
    {
        return $this->hasOne(Stamp::class, 'client_memo_id', 'id');
    }

}
