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 :: create seed file laravel 
Php :: use js in php 
Php :: php append element to array 
Php :: Laravel 5.4 Route back in blade 
Php :: php loop through object 
Php :: laravel username validation 
Php :: Regex For Iranian Phone Numbers 
Php :: enque scripts from plugin 
Php :: how to get current location latitude and longitude in php 
Php :: var_dump php 
Php :: laravel auth login with phone or email 
Php :: pluck array in laravel 
Php :: paginate relationship laravel7 
Php :: how to validate video laravel 
Php :: carbon format date in laravel 
Php :: php regular expressions 
Php :: wpdb num_rows 
Php :: laravel migrate specific table 
Php :: php How do you remove an array element in a foreach loop? 
Php :: live update mysql data in php 
Php :: PHP Forms - Required Fields 
Php :: laravel validation date 
Php :: laravel create new migration 
Php :: laravel sortby relationship column 
Php :: php convert to boolean 
Php :: ile_put_contents(/opt/bitnami/apache2/htdocs/bootstrap/cache/services.php): failed to open stream: Permission denied 
Php :: add access-control-allow-origin header laravel 
Php :: php Calculate the number of months between two dates 
Php :: if else if ternary php 
Php :: php server function 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =