@pmall Hmmm, well, I have no idea if that works because I'm getting another error that seems unrelated... perhaps you would be so kind as to help me out with that as well? Basically I have a multi-page form setup. Here's my controller:
public function show($id)
{
$instance = Instance::with(['event','venues'])->whereId($id)->first();
session()->put('instance', $instance);
return view('book.show',compact('instance'));
}
public function stepTwo(Requests\BookingFormRequest $request)
{
$data = $request->all();
$session = session()->get('instance');
session()->put('booker',$data);
return view('book.stepTwo',compact(['data','session']));
}
public function stepThree(Requests\BookStepTwoRequest $request)
{
$tickets= $request->all();
$booker = session()->get('booker');
$instance = session()->get('instance');
return 'Success';
}
Here's my routes for this part of the app:
//Booking
Route::resource('book','BookController');
Route::post('book/{id}/steptwo','BookController@stepTwo');
Route::get('book/{id}/steptwo','BookController@show');
Route::post('book/{id}/stepthree','BookController@stepThree');
Route::get('book/{id}/stepthree','BookController@show');
So to stop people jumping in further along the booking process I'm checking for GET requests and redirecting to the first page of the form, ie show.
My forms have the following methods/actions:
{!! Form::open(['method' => 'POST','action' => 'BookController@stepTwo']) !!}
{!! Form::open(['method' => 'POST','action' => 'BookController@stepThree']) !!}
Step/Page Two is where my dynamically generated fields are, incidentally. However, when I try and submit step two, I get the following error:
ErrorException in f8ededd3fac4e77e742cef8446129760 line 10:
Trying to get property of non-object (View: /home/vagrant/Code/myapp/resources/views/book/show.blade.php)
The fact that it's showing the error in show.blade.php suggests to me that it's trying to return to Step One, but I don't see why it would do that - surely it should either redirect back to Step Two if there are validation errors, or carry on to Step Three and, for now, just return a string?
EDIT: Ah-ha! I've just switched out the custom Form Request for a generic Request, and it works. So it's a problem in the custom Request, it would appear. Or the fact that it's trying to validate in any case... hmmm.