Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how make factory and seeder in laravel 8

1.make factoryu
php artisan make:factory UserFactory --model=User
2.make seeder
php artisan make:seed UserTableSeeder
Comment

laravel override factory values in database seeder

namespace DatabaseSeeders;

use AppModelsCategory;
use AppModelsPost;
use AppModelsUser;
use IlluminateDatabaseSeeder;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {
        $users = User::factory(2)->create();
        $categories = Category::factory(3)->create();
        Post::factory(3)->create([
            'user_id' => $users[0]->id,
            'category_id' => $categories[0]->id
        ]);
        Post::factory(1)->create([
            'user_id' => $users[1]->id,
            'category_id' => $categories[0]->id
        ]);
    }
}
Comment

how make factory and seeder in laravel 8

php artisan make:factory UserFactory --model=User
Comment

PREVIOUS NEXT
Code Example
Php :: Php get all timezone 
Php :: how to delete empty rows in phpmyadmin 
Php :: php new line 
Php :: if url has certain code then php 
Php :: wp main menu 
Php :: php find similitur in two array 
Php :: php check if string ends with 
Php :: trim specific character from strin using php 
Php :: laravel many to many relation update 
Php :: how to maintain serial number in pagination in laravel blade 
Php :: Laravel - Query Builder Raw Query selectRaw 
Php :: how create migration in laravel 
Php :: CSV File Read using PHP fgetcsv() 
Php :: wherein elequent 
Php :: how to download image from url from a particular div in php 
Php :: strict types php 
Php :: include in php 
Php :: excel return integer from date column laravel 
Php :: php order filename 
Php :: POP UP WITH PHP 
Php :: how to set select option value dynamically in php 
Php :: E: Unable to locate package php7.2-fpm 
Php :: How to Connect MySQL Database with PHP Websites 
Php :: wordpress wp_logout_url redirect 
Php :: laravel 5.7 
Php :: PHP MySQL Use The WHERE Clause 
Php :: laravel file store 
Php :: php file_put_contents inode problem 
Php :: laravel factory relations data 
Php :: php call constant in class 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =