company contact migration

mail@pastecode.io avatar
unknown
php
a month ago
902 B
2
Indexable
Never
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Spatie\Activitylog\Traits\LogsActivity;
use Spatie\Activitylog\LogOptions;

class CompanyContact extends Pivot
{
    use HasFactory;
    use LogsActivity;

    protected $table = 'company_contact';

    protected $casts = [
        'roles' => 'array',
    ];

    public function getActivitylogOptions(): LogOptions
    {
        return LogOptions::defaults()
            ->logOnly(['company_id', 'contact_id', 'is_point_of_contact', 'roles']);
    }

    public function contact(): BelongsTo {
        return $this->belongsTo(Contact::class);
    }

    public function company(): BelongsTo {
        return $this->belongsTo(Company::class);
    }
}
Leave a Comment