CodeCap
TRENDING
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESS
  • ARTICLES
  • TUTORIAL
No Result
View All Result
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESSNew
  • ARTICLES
  • TUTORIAL
SUBSCRIBE
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESSNew
  • ARTICLES
  • TUTORIAL
No Result
View All Result
CodeCap
No Result
View All Result
Home PHP Programming

How to create database seeder in Laravel 5.7?

How to create database seeder in Laravel 5.7?

by asdevil666
May 6, 2021
in PHP Programming
0
How to generate UUID in Laravel?
25
SHARES
158
VIEWS
Share on FacebookShare on Twitter





Here, i will explain to create seeder for insert multiple records on database table in laravel 5.7 app. in this example you will show how to use seeder and how you can run specific seeder in laravel 5.7 project.

We should know what is database seeder in laravel and why we should use before start example of database seeding. Laravel provides a tool to add sample or dummy data to our databases automatically. that is call it database seeding.

Laravel database seeder through we can add simply testing data on our database table. Database seed is extremely useful because testing with various data allows you to likely detect bugs you otherwise would have overlooked. We have to simple make one time seeder with some dummy data, that way we can simply reuse when you deploy project first time. We can make seeder after migration of table.

So today in this example we will add some sample data of users table from scratch. So laravel provide us command for creating seed and run that. so first run bellow command for create “UsersTableDataSeeder” seeder.

Create Seeder:

php artisan make:seeder UsersTableDataSeeder

After run above command successfully, you will be found new created file “database/seeds/UsersTableDataSeeder.php”. In this file i make three sample user for users table using insert query. So open UsersTableDataSeeder.php file and some sample data like as bellow:

database/seeds/UsersTableDataSeeder.php

<?php

use Illuminate\Database\Seeder;

use App\User;

class UsersTableDataSeeder extends Seeder

{

/**

* Run the database seeds.

*

* @return void

*/

public function run()

{

for ($i=0; $i < 3; $i++) {

User::create([

'name' => str_random(8),

'email' => str_random(12).'@mail.com',

'password' => bcrypt('123456')

]);

}

}

}

Now we are ready to run above seeder using bellow command:

Run Seeder:

Read Also: How to send mail using queue in Laravel 5.7?

php artisan db:seed --class=UsersTableDataSeeder

I hope it can help you….

Post Views: 558
Share10Tweet6Share3

Related Posts

How to generate UUID in Laravel?
PHP Programming

How can i print php variable in jquery?

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

Laravel Many to Many Polymorphic Relationship Tutorial

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

How to get filename from file path in MySQL?

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

How to create scroll to top of the page by jquery animate ?

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

Create Dynamic Treeview Example using JQuery Ajax in PHP MySQL

May 6, 2021
How to generate UUID in Laravel?
PHP Programming

Laravel – Category Treeview Hierarchical Structure Example with Demo

May 6, 2021
Next Post
How to generate UUID in Laravel?

How can i print php variable in jquery?

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I agree to the Terms & Conditions and Privacy Policy.

Search

No Result
View All Result

Categories

  • Android Programming
  • Android Tutorial
  • Articles
  • Business Traveller
  • Destinations
  • Extreme Work
  • General News
  • Insider Guides
  • JAVA Programming
  • JAVA Tutorial
  • PHP Error Resolve
  • PHP Programming
  • PYTHON Programming
  • PYTHON Tutorial
  • Tutorial
  • Wordpress

Tags

alert alertbox android android error application array auto autocomplete autocomplete off coding confirm box development error features form form alert function function call inspiration in_array java java error java pages javascript mobile app myql mysqli error news off php php error programming python python programming shortcode software standard
Facebook Twitter LinkedIn Youtube RSS

About Us

Codecap is the best programming for the new generation for learning and development

  • 121 King Street, Melbourne
    VIC 3000, Australia
  • codecap666@gmail.com
  • 888-123-4567

Categories

  • Android Programming
  • Android Tutorial
  • Articles
  • Business Traveller
  • Destinations
  • Extreme Work
  • General News
  • Insider Guides
  • JAVA Programming
  • JAVA Tutorial
  • PHP Error Resolve
  • PHP Programming
  • PYTHON Programming
  • PYTHON Tutorial
  • Tutorial
  • Wordpress
VIDEO: Is There Enough Programming Variability For Week 1 of the 2022 CrossFit Semifinals? – Morning Chalk Up
Tutorial

VIDEO: Is There Enough Programming Variability For Week 1 of the 2022 CrossFit Semifinals? – Morning Chalk Up

by asdevil666
May 21, 2022
0

The stage is set for week 1 of Semifinals now that we see the complete picture of programming and the...

Read more
Football: Ohio State announces times, programming updates for three games – OSU – The Lantern

Football: Ohio State announces times, programming updates for three games – OSU – The Lantern

May 21, 2022
Fox, Tubi Unveil Three New Animated Films, 2022-23 Programming Slate – Cartoon Brew

Fox, Tubi Unveil Three New Animated Films, 2022-23 Programming Slate – Cartoon Brew

May 21, 2022
TelevisaUnivision Reveals Upcoming Programming: Sofia Vergara Animated Series, Selena Quintanilla Tribute Concert, More — Upfronts – Deadline

TelevisaUnivision Reveals Upcoming Programming: Sofia Vergara Animated Series, Selena Quintanilla Tribute Concert, More — Upfronts – Deadline

May 21, 2022
Baltimore City Schools Hosts Event For Summer Programming At Maryland Science Center – CBS Baltimore

Baltimore City Schools Hosts Event For Summer Programming At Maryland Science Center – CBS Baltimore

May 21, 2022

Creation by : AMTICY

No Result
View All Result
  • Home
  • PHP
  • PYTHON
  • ANDROID
  • JAVA
  • WORDPRESS
  • ARTICLES
  • TUTORIAL

Creation by : AMTICY

Ads Blocker Image Powered by Code Help Pro
Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Refresh