<?php

namespace App\Helpers; // Or a more specific namespace if needed

use Illuminate\Support\Facades\Auth;
use App\Models\Accounts; // Use the Account model
use App\Models\GUserOptional; // Use the Account model

/**
 * Description of UserHelpers
 *
 * @author Phattharaphon
 */
class UserHelpers {

    public static function isUserLoggedIn()
    {
        $retLoggedInStatus = FALSE;
        if (Auth::check()) {
            $retLoggedInStatus =TRUE;
        }
        return $retLoggedInStatus;
    }
    
    public static function GetUserOptionalDetail($userId=null, $colName=null)
    {
        if($userId === null){
            return "";
        }
        
        $ret = "";
        //$data = Accounts::AccountsWithOptional();
        
        $data = Accounts::GetAccountsWithGUserOptional();
        echo $data;
        foreach($data as $item){
            $ret = $item->$colName;
        }
        return $ret;
    }
    
} //end class UserHelpers
