Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

niceseb's avatar

How to change prices in php artisan tinker?

In video, Jeff changed first price using

$p = All\Product::first();

$p->price = 8000

$p->save();

But how to change second, or third? There is no second, or third? There is no REPL within php artisan tinker?

0 likes
3 replies
yn95's avatar

By using skip

$p = \App\Product::skip(1)->first(); // get a second
$p = \App\Product::skip(2)->first(); // get a third

1 like
niceseb's avatar

Hi @YousifِAbbas thanks this is cool.

App\Product::all(); works;

But

$p = All\Product::skip(1)->first();

PHP Fatal error: Class 'All\Product' not found in eval()'d code on line 1 ?

1 like
yn95's avatar

please change

$p = All\Product::skip(1)->first();

to

$p = \App\Product::skip(1)->first();

And you are welcome anytime :) @niceseb

1 like

Please or to participate in this conversation.