I'm trying to make 2 buttons with Mars as Paid
and Mark as Unpaid
values 1/0.
When I click on button I've got error:
Creating default object from empty value
What is wrong with the code? I know it can be write more 'intelligent'. Here is the controller
public function ordersPaidSubmit($orderId) {
$order = Order::where('order_id', $orderId)->first();
if (!$order) {
App::abort(404);
}
$paid->paid = Input::get('paid');
$order->save();
return Redirect::to('/orders')->with('message', '');
}
And here is view buttons
{{ Form::open() }}
@if($order->paid = 0)
<button type="submit" class="btn btn-primary" name="paid" id="paid" value="1">Mark Order as Paid</button>
@else
<button type="submit" class="btn btn-primary" name="paid" id="paid" value="0">Mark Order as Unpaid</button>
@endif
{{ Form::close() }}