1
나는 묵시적인 관계에 문제가 있습니다. 관계는 ... 각 사용자는 사용자이기도 한 소유자를 가질 수 있습니다.Laravel 4 관계 및 이벤트
나는 부모와 함께 사용자를 가져올 때 :
유닉스 계열의 OS 및 PHP 5.4.20에부모와 사용자 모두가 동일하므로, 나는 부모와 동일한 사용자를 얻을.
반면에 PHP5.4.7 (중요한 점은 7)에서 올바른 데이터를 반환합니다. 그런데이 코드는 이벤트의 이벤트 핸들러입니다.
사용자 모델 난 당신이 incorect입니다 반전 생각
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');
}
}
당신이 우리와 함께'User' 모델을 공유 할 수 확인하십시오? – msturdy
물론입니다. http://laravel.io/bin/kon4m –
관계를 쿼리하는 위치에서 코드를 공유 할 수 있습니까? 그 모형은 바르게 보인다 – msturdy