Advertisement
Whistik

Untitled

Sep 14th, 2017
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 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.     /**
  11.     * @var \App\Http\Steam The Steam class instance
  12.     */
  13.     private $_Steam;
  14.    
  15.     /**
  16.     * @var array
  17.     */
  18.     public $_LocalInventory;
  19.  
  20.     public function __construct()
  21.     {
  22.  
  23.         // Initializing an Steam class
  24.         $this->_Steam = new \App\Http\Steam();
  25.    
  26.     }
  27.    
  28.     /**
  29.     * The constructor for an index page
  30.     *
  31.     * @return Illuminate\Support\Facades\View
  32.     */
  33.     public function index()
  34.     {
  35.  
  36.         if( !$this->isLogged() )
  37.             return redirect('/');
  38.  
  39.         $this->_LocalInventory = \App\Client::where('steamid', '=', $_SESSION['steamID64'])->value('inventory');
  40.  
  41.         $application = new ApplicationController();
  42.         $steamController = new SteamController();
  43.  
  44.         return view('site.profile')
  45.             ->with('app', \App\Application::all())
  46.             ->with('application', $application)
  47.             ->with('case', \App\Cases::all())
  48.             ->with('client', $this)
  49.             ->with('localinventory', $this->_LocalInventory)
  50.             ->with('steam', $this->_Steam)
  51.             ->with('steamController', $steamController)
  52.             ->with('steaminventory', '[]'); // TODO: Make an request for user inventory on Steam
  53.  
  54.     }
  55.  
  56.     /**
  57.     * Getting an client data from a database
  58.     *
  59.     * @param int $steamid Unique Steam64 ID
  60.     * @param mixed $data Data, which will be fetched from a database
  61.     * @param bool|true $json Selector, if data's are in json
  62.     * @return string
  63.     */
  64.     public function GetClient($steamid, $data, $json = true)
  65.     {
  66.         if( $json == true )
  67.             return json_decode( \App\Client::where('steamid', '=', $steamid)->get()[0]['data'] )->$data;
  68.         else
  69.             return \App\Client::select($data)->where('steamid', $steamid)->value($data);
  70.     }
  71.  
  72.     /**
  73.     * Checking if a client is logged
  74.     *
  75.     * @return bool
  76.     */
  77.     public static function isLogged()
  78.     {
  79.         return isset($_SESSION['steamID64']) ? true : false;
  80.     }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement