first commit

This commit is contained in:
2025-03-05 21:11:33 -06:00
commit ac40d0f399
46 changed files with 6283 additions and 0 deletions

View File

@ -0,0 +1,56 @@
<?php
namespace Koneko\VuexyAdmin\Models;
use Illuminate\Database\Eloquent\Model;
use Koneko\VuexyAdmin\Services\ContactableItemService;
class ContactableItem extends Model
{
protected $table = 'contactable_items';
protected $fillable = [
'contactable_id',
'contactable_type',
'type',
'data_contact',
'preference_level',
'notes'
];
protected $casts = [
'preference_level' => 'integer',
];
/**
* Relación polimórfica con cualquier modelo (User, Empresa, etc.)
*/
public function contactable()
{
return $this->morphTo();
}
/**
* Devuelve la información del tipo de contacto desde `settings`
*/
public function getTypeInfoAttribute()
{
return app(ContactableItemService::class)->getTypeById($this->type);
}
/**
* Devuelve el nombre del tipo de contacto
*/
public function getTypeTextAttribute()
{
return $this->type_info['label'] ?? 'Desconocido';
}
/**
* Devuelve el icono del tipo de contacto
*/
public function getTypeIconAttribute()
{
return $this->type_info['icon'] ?? 'ti-help-circle';
}
}