<?php

namespace Modules\Travel\Entities;
use App\Models\User;
use App\Models\Branch;
use App\Models\Upload;
use App\Models\Company\Company;
use App\Models\Traits\BranchTrait;
use App\Models\Traits\CompanyTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\coreApp\Traits\Relationship\StatusRelationTrait;

class TravelMeeting extends Model
{
    use HasFactory, StatusRelationTrait, CompanyTrait, BranchTrait;

    protected $fillable = [
        'travel_plan_id',
        'date',
        'customer_company_name',
        'customer_name',
        'customer_email',
        'customer_phone',
        'purpose_of_travel',
        'meeting_time',
        'remark',
        'file_id',
        'rating',
        'feedback',
        'created_by',
        'updated_by',
        'company_id',
        'branch_id',
    ];

    /**
     * Get the travel plan that owns the travel purpose.
     */
    public function travelPlan()
    {
        return $this->belongsTo(TravelPlan::class, 'travel_plan_id');
    }

    /**
     * Get the file associated with the travel purpose.
     */
    public function file()
    {
        return $this->belongsTo(Upload::class, 'file_id');
    }

    /**
     * Get the user who employee the travel purpose.
     */
    public function employee()
    {
        return $this->belongsTo(User::class, 'employee_id');
    }

    /**
     * Get the user who created the travel purpose.
     */
    public function creator()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    /**
     * Get the user who updated the travel purpose.
     */
    public function updater()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }

    /**
     * Get the company associated with the travel purpose.
     */
    public function company()
    {
        return $this->belongsTo(Company::class, 'company_id');
    }

    /**
     * Get the branch associated with the travel purpose.
     */
    public function branch()
    {
        return $this->belongsTo(Branch::class, 'branch_id');
    }

    public function createdBy()
    {
        return $this->belongsTo(User::class, 'created_by');
    }

    public function updatedBy()
    {
        return $this->belongsTo(User::class, 'updated_by');
    }

    public function rejectedBy()
    {
        return $this->belongsTo(User::class, 'rejected_by');
    }
}
