public static function getDevice($key = null, $val = null) { if (is_null($key)) { $c = Device::get(); self::$device = $c; return new self(); } else { $c = Device::where($key, '=', $val)->first(); self::$device = $c; return $c; } }