我想开始在Eclipse中使用Java 8,但我不知道如何安装它 - 我找不到任何关于它的教程.我正在使用Eclipse Kepler并为IDE添加了JDK 8的JRE,但由于JRE版本的合规性问题,它不会让我继续创建项目.如何在Eclipse Kepler IDE中使用Java 8?
我有一个名为'posts'的表,其中包含以下列:'post_id int primary incrementments','poster_id int'和'status text'以及名为friends的数组,其中包含以下列:'user_id int primary'和'friend_ids text'.
我需要获取朋友文本列中的所有ID,这很容易使用:
$friends = explode(',', \Friend::where('user_id', \Sentry::getUser()->id)->first()->friend_ids);
Run Code Online (Sandbox Code Playgroud)
文本列中的数据看起来像'1,2,3'等.
然后我创建一个Eloquent Collection对象,也可以通过以下方式轻松完成:
$posts = new \Illuminate\Database\Eloquent\Collection();
Run Code Online (Sandbox Code Playgroud)
但问题是我无法弄清楚如何填充集合并通过Post对象的'created_at'列对其内容进行排序.
这就是我现在所拥有的:
foreach ($friends as $id) {
$posts_ = \Post::where('poster_id', $id)->getQuery()
->orderBy('created_at', 'desc')
->get();
foreach($posts_ as $post) {
$posts->add($post);
}
}
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚这个代码是否适用于通过'created_at'列对整个帖子集合进行排序.我还需要能够轻松地对整个集合进行分页.
对集合进行排序的推荐方法是什么?
来自Bootstrap的旋转木马不会显示我的图像或对控件做出反应.
这是我的HTML:
<!DOCTYPE HTML>
<html>
<head>
<title>Skates R Us</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/global.css">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#" class="navbar-brand">
Skates R Us
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">
<a href="index.html">Home</a>
</li>
<li>
<a href="contact.html">Contact / About</a>
</li>
<li>
<a href="shop.html">Shop</a>
</li>
<li>
<a href="new.html">New Products</a>
</li>
<li> …Run Code Online (Sandbox Code Playgroud) 我正在使用Laravel中提供的基本HTTP身份验证登录我的网站.但是,当我打电话时,即使我已登录,Auth::Check()我总是得到错误的回复.
难道Auth::Check()不符合基本的身份验证模式工作,如果没有,有没有什么办法来检查基本身份验证,看是否有用户登录?
这是我的用户类:
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'email', 'password',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function getRememberToken()
{
return $this->remember_token;
}
public function setRememberToken($value)
{
$this->remember_token = $value;
}
public function getRememberTokenName() …Run Code Online (Sandbox Code Playgroud) 我有一个Users表,一个Images表和一个Bookmarks表.我已经在我的数据库中指定了每个关系,我能够访问用户上传的所有图像.但是,我无法访问他们已添加书签的图像.
这就是我的数据库关系的样子:

我可以使用PHPMyAdmin上的SQL输入访问我想要的数据但是在使用Laravel时我无法访问:

使用Laravel会产生以下错误:

这是我的用户模型:
<?php
use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;
use Cartalyst\Sentry\Users\Eloquent\User as SentryUserModel;
class User extends SentryUserModel implements UserInterface, RemindableInterface {
public $activated = true;
public function getAuthIdentifier() {
return $this->getKey();
}
public function getAuthPassword() {
return $this->password;
}
public function getRememberToken() {
return $this->remember_token;
}
public function setRememberToken($value) {
$this->remember_token = $value;
}
public function getRememberTokenName() {
return 'remember_token';
}
public function getReminderEmail() {
return $this->email;
}
public function images() {
return $this->hasMany('image', 'poster_id', 'id');
}
public function …Run Code Online (Sandbox Code Playgroud) 我有以下课程:
final class CFS {
public Map<String, String> files = new HashMap<String, String>();
public List<String> directories = new ArrayList<String>();
}
Run Code Online (Sandbox Code Playgroud)
这段代码应该解析json:
CFS cfs = JStorage.getGson().fromJson(JSON_STRING, CFS.class);
Run Code Online (Sandbox Code Playgroud)
哪里
JSON_STRING = "{\"directories\" : [\"folder1\", \"folder1/folder2\"], \"files\" : [{\"folder1\" : \"file.txt\"}, {\"folder1/folder2\" : \"file.cfg\"}]}"
Run Code Online (Sandbox Code Playgroud)
JSON是:
{
"directories": ["folder1", "folder1/folder2"],
"files": [
{
"folder1": "file.txt"
},
{
"folder1/folder2": "file.cfg"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误是: Expected BEGIN_ARRAY but was STRING at line 1 column 62
但是我不知道为什么,根据jsonlint,json是有效的。
我为什么会收到此错误的任何想法吗?
如果用户按下键盘上的"A"键,我有一个想要播放的动画.动画正面向文件并正常播放,直到我尝试翻转纹理.
当我尝试在玩家的方向改变时翻转纹理时会发生这种情况:

正如您所看到的,动画在开始时播放得很好,但是当我改变播放器的方向时,它会在翻转的帧和未打开的帧之间交替.
这是我的玩家类:
package unit22.game;
import java.util.ArrayList;
import unit22.core.Utils;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
public class Player {
private PlayerState state = PlayerState.STANDING;
private Direction direction = Direction.RIGHT;
private int x = 0, y = 0, width = 0, height = 0;
private PlayerInputProcessor inputProcessor;
private String name;
private ArrayList<Action> actions;
private Animation standingAnim;
private Animation movingAnim;
private float stateTime;
private SpriteBatch spriteBatch;
private Action currentAction;
private Animation currentAnimation;
public Player(String name, int x, int y, …Run Code Online (Sandbox Code Playgroud) 我的网站上有一个搜索页面,您可以输入一个人的用户名来显示他们的个人资料,尽管只有当您输入他们的完整用户名时才能使用.我想检查一行用户名列是否包含用户输入的字符序列,这样当他们输入时:'Mr'它会显示结果'MrDare360'等等.
这是我目前的代码:http://pastebin.com/68dgLZf8
这样做最简单或最好的方法是什么?
例如,如果我定义了一个触发器,当该帖子被删除时删除该帖子的所有评论。当用户被删除时删除所有帖子的触发器会激活另一个触发器从而删除评论吗?