Advertisement
Whistik

Untitled

Sep 3rd, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.89 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Controllers;
  4.  
  5. use Illuminate\Http\Request;
  6.  
  7. class ClientController extends Controller
  8. {
  9.  
  10.     private $_Steam;
  11.     public $_LocalInventory;
  12.  
  13.     public function __construct()
  14.     {
  15.  
  16.         $this->_Steam = new \App\Http\Steam();
  17.    
  18.     }
  19.    
  20.     /**
  21.     * Constructor for index page
  22.     *
  23.     * @return mixed View blade template with data's
  24.     */
  25.     public function index()
  26.     {
  27.  
  28.         if( $this->_Steam->IsUserLoggedIn() == false )
  29.             return redirect('/');
  30.  
  31.         $application = new ApplicationController();
  32.         $api = new ApiController();
  33.  
  34.         return view('site.profile')
  35.             ->with('app', \App\Application::all())
  36.             ->with('case', \App\Cases::all())
  37.             ->with('client', $this)
  38.             ->with('steam', $this->_Steam)
  39.             ->with('application', $application)
  40.             ->with('api', $api)
  41.             ->with('localinventory', $this->_LocalInventory)
  42.             ->with('steaminventory', $application->_SteamInventory);
  43.  
  44.     }
  45.  
  46.     /**
  47.     * Getting client data's from database
  48.     *
  49.     * @param int id Unique Steam64 ID
  50.     * @param mixed data Selected data to fetch
  51.     * @param bool json Is selecting from json or not
  52.     * @return string Fetched data
  53.     */
  54.     public function GetClient($steamid, $data, $json = true)
  55.     {
  56.         if( $json == true )
  57.             return json_decode( \App\Client::where('steamid', '=', $steamid)->get()[0]['data'] )->$data;
  58.         else
  59.             return \App\Client::select($data)->where('steamid', $steamid)->value($data);
  60.     }
  61.  
  62.     /**
  63.     * Checking if client is logged
  64.     *
  65.     * @param string ip Real client ip (HTTP_CF_CONNECTING_IP)
  66.     * @return bool true/false
  67.     */
  68.     public static function isLogged($ip)
  69.     {
  70.         return count(\App\LoggedUser::where('ip', '=', $ip)->count()) > 0 ? true : false;
  71.     }
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement