我正在尝试与Eloquent建立一个hasManyTrough关系,但目前还不清楚它是如何从文档中运行的.
表:
users
- id
- firstname
- ...etc
accounts
- id
- user_id
- username
- ...etc
roles
- id
- permissions
account_role
- id
- account_id
- role_id
Run Code Online (Sandbox Code Playgroud)
楷模
<?php
class User extends Eloquent {
public function account()
{
return $this->hasOne('Account');
}
// This is what I'm trying to achieve
public function roles()
{
return $this->hasManyThrough('Role', 'Account');
}
}
class Role extends Eloquent {
public function accounts()
{
return $this->belongsToMany('Account')->withTimestamps();
}
}
class Account extends Eloquent {
public …
Run Code Online (Sandbox Code Playgroud) 当我在PHP(v5.5.9)中执行以下代码时,会发生意外情况:
$valueAsCents = 54780 / 100 * 100;
var_dump($valueAsCents);
var_dump((int) $valueAsCents);
Run Code Online (Sandbox Code Playgroud)
这回来了
float 54780
int 54779
Run Code Online (Sandbox Code Playgroud)
所以显然没有小数的浮点值不等于int值.关于这里发生了什么的任何想法?