<?php 

use App\Models\UserModel;
use App\Models\ConnectionModel;


function getNameUser()
{
	$UserModel = new UserModel();

	$row = $UserModel->first(session()->get('id'));


	if(!empty((array) $row )){
		return $row->first_name.' '.$row->last_name;
	}

	return "User";

}


function getProfileUser()
{
	$UserModel = new UserModel();

	$row = $UserModel->first(session()->get('id'));


	if(!empty((array) $row )){
		return $row->image;
	}

	return "default-profile.png";

}


function getIp()
{
	$ConnectionModel = new ConnectionModel();
	$row = $ConnectionModel->first();
	
	if(empty($row->ip)){
		return [];
	}

	return $row->ip;

}

function formatDate($datetime) {
    date_default_timezone_set('Asia/Jakarta');
    
    return date('j F Y', strtotime($datetime));
}

function formatTime($datetime) {
    date_default_timezone_set('Asia/Jakarta');
    
    return date('H:i', strtotime($datetime)) . ' WIB';
}

