jeudi 2 mars 2017

Method save does not exist occur after lockForUpdate Laravel 5.1

Laravel Cannot Save data to DB after Pessimistic Locking

I am facing the problem that cannot update data to db while using save method with Laravel 5.1.

I am trying to update data with locking to avoid concurrency data and below is my code.

Please help me.

namespace App\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
class Recharge extends Model
{
public function processSuccess($orderId, $type, $amount) {
        $query = [
            ['status', '<=', 1],
            ['order_abm', '=', $orderId],
            ['type', '=', $type],
            ['amount', '=', $amount],
        ];

        \DB::beginTransaction();
        $concur_up = Recharge::where($query)->lockForUpdate()->get();
        $concur_up->status = 5;
        $concur_up->amounted = $amount;
        $concur_up->date    = time();
        $res =$concur_up->save();
        if (!$res) {
            return "fail";
        }
        \DB::commit();
        return true;
    }
}

error shown in my editor

enter image description here

error shown in my browser

enter image description here

My using table

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire