<?php

namespace App\Http\Controllers;

use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Support\Facades\Log;

use App\Http\Controllers\AuthController;
use App\Http\Controllers\UserController;
use App\Http\Controllers\PermissionController; // Remove permission controller soon.

class PackageController extends Controller {
  private $objAuth;
  private $objUser;
  private $objPermission;

  public function __construct() {
    $this->objAuth = new AuthController();
    $this->objUser = new UserController();
    $this->objPermission = new PermissionController();
  }

  public function get(Request $r) { // /api/rpc/pack/get
    $check = $this->objAuth->checkLegit($r->kero_token);

    if ($check == 0) {
      return 'err!';
    }
    else {
      return DB::table('pck_tracks')
        ->select('*')
        ->where('user_id', $check)
        ->orderBy('id', 'desc')
        ->get();
    }
  }
}
