Files
2026-04-24 21:40:10 -05:00

45 lines
1.2 KiB
PHP

<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class WhatsappUser extends Model
{
protected $table = 'whatsapp_users';
protected $fillable = [
'phone_number', 'name', 'status', 'current_menu_id', 'current_step',
'session_data', 'welcome_sent_at', 'in_service', 'in_service_by',
'on_hold', 'bot_paused_until', 'advisor_requested', 'bot_enabled',
'terms_pending', 'terms_accepted_at', 'terms_version_id',
];
protected $casts = [
'session_data' => 'array',
'welcome_sent_at' => 'datetime',
'bot_paused_until' => 'datetime',
'terms_accepted_at' => 'datetime',
'in_service' => 'boolean',
'on_hold' => 'boolean',
'advisor_requested' => 'boolean',
'bot_enabled' => 'boolean',
'terms_pending' => 'boolean',
];
public function conversations()
{
return $this->hasMany(WhatsappConversation::class, 'user_id');
}
public function lastMessage()
{
return $this->hasOne(WhatsappConversation::class, 'user_id')->latestOfMany();
}
public function currentMenu()
{
return $this->belongsTo(WhatsappMenu::class, 'current_menu_id');
}
}