2016-06-03 2 views
0

로부터 모델을 재건 I가 세션 내로 organisation 오브젝트를 배치하는 다음 코드를 사용자가 organisationLaravel 5 어레이

{!! Form::model($organisation, ['route' => 'setup.organisation', 'method' => 'POST']) !!} 
    @include('setup.organisation-form') 
{!! Form::close() !!} 
의 내용을 수정할 수 I는 ( laravelcollective 사용) 형태를 가질

session()->put('tenant.organisationActive', $organisation->toArray()); 

내가 session에서 $organisation를로드 할,이 시도 :

$organisation = new Organisation; 
if (session()->has('tenant.organisationActive.id')) { 
    $organisation = collect(session('tenant.organisationActive')); 
} 
return view('setup.wizard', compact('organisation'); 

dd을 통해 알 수 있습니다. 위의 예제에서 데이터는 organisation 컬렉션으로 전달되지만 데이터를 포함하는 하나의 배열의 컬렉션입니다.

Undefined property: Illuminate\Support\Collection::$address1 

나는 collect 기능을 사용하지 않을 경우, 오류가 나는 이것에 대한 이유는 laravelcollective이 모델의 속성에 액세스 있다는 것을 의심

Trying to get property of non-object 

된다 : 페이지가 열립니다 실패 , 배열 키가 아닌.

그렇다면 세션 배열을 기반으로 개체를 다시 작성하는 방법은 무엇입니까? 감사!

답변

0

Doh! 긴 하루. 대답은 다음과 같습니다.

$organisation = new Organisation(session('tenant.organisationActive'));