Larastan: lockForUpdate() is not supported in Query Builder

Created on 27 Oct 2020  路  4Comments  路  Source: nunomaduro/larastan

  • Larastan Version: v0.6.8
  • --level used: 2

Description

When I call firstOrFail() after lockForUpdate(), I get the error.

Call to an undefined method Illuminate\Database\Query\Builder::firstOrFail()

Neither first() nor get() occurs the problem.

Laravel code where the issue was found

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    public function test()
    {
        return $this
            ->where('id', 1)
            ->lockForUpdate()
            ->firstOrFail();
    }
}

Last but not least, thank you very much for creating this product!

bug false positive

Most helpful comment

Hi,

Thank you for reporting. This looks like a false positive. I'll check it :+1:

All 4 comments

Thank you for your report.
What is the situation when you remove lockForUpdate?

Thank you for quick response.

What is the situation when you remove lockForUpdate?

Error has gone away.

Hi,

Thank you for reporting. This looks like a false positive. I'll check it :+1:

Was this page helpful?
0 / 5 - 0 ratings