33 lines
		
	
	
		
			687 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			687 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(Card::class, 'card_id');
 | 
						|
    }
 | 
						|
 | 
						|
    /* convenience: return tags as array */
 | 
						|
    public function getTagsArrayAttribute(): array
 | 
						|
    {
 | 
						|
        return $this->tags
 | 
						|
            ? array_map('trim', explode(',', $this->tags))
 | 
						|
            : [];
 | 
						|
    }
 | 
						|
}
 |