更改付款状态按钮给出错误 "Creating default object..."

Change payment status buttons gives error "Creating default object..."

我正在尝试使用 Mars as PaidMark as Unpaid 值 1/0 制作 2 个按钮。

当我点击按钮时出现错误:

Creating default object from empty value

代码有什么问题?我知道可以多写'intelligent'。 这是控制器

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', '');
}

这是查看按钮

{{ 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() }}

问题似乎出在您从表单中获取 paid 值的控制器中。尝试替换:

$paid->paid

惠特

$paid['paid']

这条线

$paid->paid = Input::get('paid');