Laravel Tinker Finding a record and using constraints

We’ll go into the command line to create a new entry in posts:

php artisan tinker

Now find a record:

$post = App\Models\Post::find(4);

To use constraints write:

$post = App\Models\Post::where('id',4)->first();
$post = App\Models\Post::whereId(4)->first();

Leave a Reply

Your email address will not be published.