Laravel 4关系和事件
我对有说服力的关系有意见。关系是。。。每个用户都可以有一个所有者,该所有者也是一个用户 当我尝试获取具有父级的用户时: 在*nix OS和PHP5.4.20上,我得到的用户和父用户相同,所以父用户和用户都是相同的 而在PHP5.4.7上(如果有必要,则为win7),它返回正确的数据。顺便说一下,这段代码是某个事件的事件处理程序 用户模型Laravel 4关系和事件,laravel,laravel-4,eloquent,Laravel,Laravel 4,Eloquent,我对有说服力的关系有意见。关系是。。。每个用户都可以有一个所有者,该所有者也是一个用户 当我尝试获取具有父级的用户时: 在*nix OS和PHP5.4.20上,我得到的用户和父用户相同,所以父用户和用户都是相同的 而在PHP5.4.7上(如果有必要,则为win7),它返回正确的数据。顺便说一下,这段代码是某个事件的事件处理程序 用户模型 class User extends Eloquent implements UserInterface, RemindableInterface, Prese
class User extends Eloquent implements UserInterface, RemindableInterface, PresentableInterface {
protected $fillable = array(
'first_name', 'last_name', 'email', 'password', 're_type_password', 'birth_date',
'phone', 'address', 'state', 'city', 'zip', 'profile_pic', 'owner_id', 'can_edit_appointments',
'can_accept_invitations', 'can_edit_profile', 'can_receive_notification', 'is_active', 'is_admin', 'token', 'failed_login_attempts_count'
);
public function __construct($validator = null, $subAccountValidator = null)
{
parent::__construct();
$this->validator = $validator ?: App::make('ReminderMillie\Services\Validators\UserValidator');
$this->subAccountValidator = $subAccountValidator ?: App::make('ReminderMillie\Services\Validators\SubAccountValidator');
}
public function getDates()
{
return array('created_at', 'updated_at', 'birth_date');
}
/**
* Relations
*/
public function business()
{
return $this->hasOne('Business', 'owner_id');
}
public function parent()
{
return $this->belongsTo('User', 'owner_id');
}
public function subAccounts()
{
return $this->hasMany('User', 'owner_id');
}
}
我认为你是不正确的 请检查这个
public function parent()
{
return $this->belongsTo('User');
}
public function subAccounts()
{
return $this->hasMany('User', 'id', 'owner_id');
}
你能和我们分享
用户
型号吗?当然可以。您还可以在查询关系的地方共享代码吗?那个型号看起来不错。问题在线上#53我看不出有什么理由会这样做。。两台机器(即*nix和windows 7机器)之间数据库中的数据是否相同?