Laravel-auditing: Call to undefined method Illuminate\Database\Query\Builder::last()

Created on 21 May 2018  路  3Comments  路  Source: owen-it/laravel-auditing

| Q | A
| ----------------- | ---
| Bug? | no (error)
| New Feature? | no
| Framework | Laravel
| Framework version | 5.4.*
| Package version | 7.0.0
| PHP version | 7.2.4

Actual Behaviour

Get last Audit

Error

Call to undefined method Illuminate\Database\Query\Builder::last()
although fetching all audits work fine
Audit::all();

invalid V7

Most helpful comment

ya m doing that,
its mentioned in the documentation.

// Get last Audit
$last = $article->audits()->last();

i gusess then it should be removing from documentation.

All 3 comments

I think the error message is pretty much self explanatory. There's no such method in the query builder by that name.

This isn't related to the package itself, more to Eloquent/Builder.

Try sorting by latest and get the first.

ya m doing that,
its mentioned in the documentation.

// Get last Audit
$last = $article->audits()->last();

i gusess then it should be removing from documentation.

It should be $last = $article->audits->last(); instead. Thanks for the heads up.

Was this page helpful?
0 / 5 - 0 ratings