| Server IP : 13.235.167.51 / Your IP : 216.73.217.116 Web Server : Apache System : Linux machinox-server 6.17.0-1013-aws #13~24.04.1-Ubuntu SMP Fri Apr 24 21:36:58 UTC 2026 aarch64 User : root ( 0) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/app.machinox.in/app/Models/ |
Upload File : |
<?php
namespace App\Models;
use App\Helpers\UtilityHelper;
use App\Traits\UploadTrait;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
class Message extends Model
{
use SoftDeletes, HasFactory, UploadTrait;
protected $fillable = [
'gd_id',
'sender_id',
'message',
'is_read',
];
protected $hidden = [
'created_at',
'updated_at',
'deleted_at',
];
protected $appends = ['created_at_formatted'];
public function sender()
{
return $this->belongsTo(User::class, 'sender_id');
}
public function groupChat()
{
return $this->belongsTo(GroupChat::class, 'gd_id');
}
public function getMessageAttribute($value)
{
if ($this->type === 'TEXT') {
return $value;
}
$folder = config("constants.ATTACHMENTS");
return $this->getURL($folder, $value);
}
public function getCreatedAtFormattedAttribute()
{
$locale = app()->getLocale();
$timezone = 'Asia/Kolkata';
\Carbon\Carbon::setLocale($locale);
return optional($this->created_at)
->copy()
->setTimezone($timezone)
->translatedFormat('d M Y, h:i A'); // e.g., 01 Jul 2025, 04:25 PM
}
}