kithkin/app/Models/ContactMeta.php

33 lines
690 B
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ContactMeta extends Model
{
protected $table = 'contact_meta';
protected $primaryKey = 'card_id';
public $incrementing = false;
protected $fillable = [
'avatar_url',
'tags',
'notes',
];
public function contact(): BelongsTo
{
return $this->belongsTo(Contact::class, 'card_id');
}
/* convenience: return tags as array */
public function getTagsArrayAttribute(): array
{
return $this->tags
? array_map('trim', explode(',', $this->tags))
: [];
}
}