php artisan tinker

Print this article
Font size -16+
This terminal command provides a REPL (Read-Eval-Print Loop) for PHP with your application’s settings already loaded:
php artisan tinker
You can insert rows in a table:
DB::table(‘cards’)->insert([‘title’=>’My First Card’,’created_at’=>DateTime,’updated_at’=>new DateTime])
You can display rows from a table:
DB::table(‘cards’)->get();
Get me the first result from table cards where title is ‘My new card’
DB::table(‘cards’)->where(‘title’,’My New Card’)->first();
Delete from table cards where title is ‘My new card’
DB::table(‘cards’)->where(‘title’,’My New Card’)->delete();