How to use Tinker in Laravel for Creating a Record in Laravel

We’ll talk about how to use one of Laravel’s lesser-known features to quickly read data from our Laravel applications. We can use Laravel artisan’s built-in php artisan tinker to mess around with your application and things in the database.


C:\wamp\www\project>php artisan tinker
Psy Shell v0.8.17 (PHP 7.1.9 — cli) by Justin Hileman
>>> $post = new App\Post();
=> App\Post {#775}
>>> $post->title = 'Post Three';
=> "Post Three"
>>> $post->body = 'Body of the post three';
=> "Body of the post three"
>>> $post->save();
=> true

You may also like...