Файловый менеджер - Редактировать - /home/clickysoft/public_html/travel-guru.clickysoft.net/app/Models/UserChat.php
Назад
<?php namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; class UserChat extends Model { use HasFactory; // The table associated with the model (optional if the model name matches the table name) protected $table = 'user_chats'; // The attributes that are mass assignable protected $fillable = [ 'sender_id', 'receiver_id', 'message', 'status', 'file_name', 'file_path', 'file_type', ]; /** * Get the user who sent the message. */ public function sender() { return $this->belongsTo(User::class, 'sender_id'); } /** * Get the user who received the message. */ public function receiver() { return $this->belongsTo(User::class, 'receiver_id'); } /** * Scope a query to only include unread messages. */ public function scopeUnread($query) { return $query->where('status', 'unread'); } /** * Scope a query to only include read messages. */ public function scopeRead($query) { return $query->where('status', 'read'); } /** * Scope a one to one message */ public function scopeOneToOneChat($query, $authUserId, $userId) { return $query->where(function ($query) use ($authUserId, $userId) { $query->where('sender_id', $authUserId) ->where('receiver_id', $userId); })->orWhere(function ($query) use ($authUserId, $userId) { $query->where('sender_id', $userId) ->where('receiver_id', $authUserId); }); } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.29 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка