mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
messages view
This commit is contained in:
@ -5,14 +5,15 @@ namespace App\Models\Chat;
|
||||
use App\Models\ChatNotification;
|
||||
use App\Models\Usuarios\UserModel;
|
||||
use CodeIgniter\Model;
|
||||
use CodeIgniter\Database\BaseBuilder;
|
||||
|
||||
class ChatMessageModel extends Model
|
||||
{
|
||||
protected $table = 'chat_messages';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $returnType = 'object';
|
||||
protected $useSoftDeletes = true;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [
|
||||
"message",
|
||||
@ -29,7 +30,7 @@ class ChatMessageModel extends Model
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $useTimestamps = true;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
@ -72,6 +73,23 @@ class ChatMessageModel extends Model
|
||||
}
|
||||
return $messages;
|
||||
}
|
||||
public function get_chat_message(int $chat_message_id): object
|
||||
{
|
||||
$user = model(UserModel::class);
|
||||
$auth_user = auth()->user();
|
||||
$message = $this->find($chat_message_id);
|
||||
$message->pos = $auth_user->id == $message->sender_id ? "right" : "left";
|
||||
if ($auth_user->id == $message->sender_id) {
|
||||
$message->sender_first_name = $auth_user->first_name;
|
||||
$message->sender_last_name = $auth_user->last_name;
|
||||
|
||||
} else {
|
||||
$sender_user = $user->find($message->sender_id);
|
||||
$message->sender_first_name = $sender_user->first_name;
|
||||
$message->sender_last_name = $sender_user->last_name;
|
||||
}
|
||||
return $message;
|
||||
}
|
||||
public function get_chat_contact_messages(int $receiver_id): array
|
||||
{
|
||||
$conversationArray = [];
|
||||
|
||||
Reference in New Issue
Block a user