DEV Community

Cover image for How to Create a User using Tinker in Laravel
saim
saim

Posted on • Originally published at larainfo.com

6

How to Create a User using Tinker in Laravel

Tinker allows you to interact with your entire Laravel application on the command line, including the Eloquent ORM, jobs, events, and more. To enter the Tinker environment, run the tinker Artisan command.

php artisan tinker or php artisan ti 
Enter fullscreen mode Exit fullscreen mode

By using the tinker command line, we can create a new user or insert new data into the database.

Now run php artisan ti

Psy Shell v0.10.6 (PHP 7.4.16  cli) by Justin Hileman
>>> User::create(["name"=> "larainfo","email"=>"larainfo@gmail.com","password"=>bcrypt("123456")]);
=> App\Models\User {#4290
   name: "larainfo",
   email: "larainfo@gmail.com",
   updated_at: "2021-04-22 08:23:28",
   created_at: "2021-04-22 08:23:28",
   id: 1,
  }
>>> 
Enter fullscreen mode Exit fullscreen mode

Or you can explore different approaches to storing new data. Let's see.
php artisan ti

>>> $user = new App\Models\User;
=> App\Models\User {#4301}
>>> $user->name = "larainfo";
=> "larainfo"
>>> $user->email= "larainfo@gmail.com";
=> "larainfo@gmail.com"
>>> $user->password=bcrypt('123456');
=> "$2y$10$uSdO/eBCQPNK3eVjXlSh.ulBVamZOhc.Hu5bp8Xzzb.uWyS3MSwRC"
>>> $user->save();
=> true
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more