php artisan run factory code example
Example 1: php artisan make factory
php artisan make:factory AddressFactory --model="App\\Address"
Example 2: laravel 8 seeding
php artisan db:seed
php artisan db:seed --class=UserSeeder
Example 3: laravel 8 seeding
/**
* Run the database seeders.
*
* @return void
*/
public function run()
{
$this->call([
UserSeeder::class,
PostSeeder::class,
CommentSeeder::class,
]);
}
Example 4: laravel 7 generator
use App\Http\Resources\UserCollection;
use App\User;
Route::get('/users', function () {
return new UserCollection(User::all());
});