The database_path function returns the fully qualified path to your application's database directory. You may also use the database_path function to generate a fully qualified path to a given file within the database directory:
<?php $path = database_path();

$path = database_path('factories/UserFactory.php');
<?php             ->replaceFirst('App\\Models\\', '')

            ->replaceFirst('App\\', '');



        return database_path('factories/' . str_replace('\\', '/', $subDirectory) . 'Factory.php');

    }
<?php         $this->beforeApplicationDestroyed(function () {

            File::cleanDirectory(app_path());

            File::cleanDirectory(database_path('factories'));

        });

    }
<?php             ->expectsOutput('3 factories created')

            ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertFileExists(database_path('factories/HabitFactory.php'));

        $this->assertFileExists(database_path('factories/UserFactory.php'));

    }
<?php             ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertFileExists(database_path('factories/HabitFactory.php'));

        $this->assertFileExists(database_path('factories/UserFactory.php'));

    }
<?php         $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertFileExists(database_path('factories/HabitFactory.php'));

        $this->assertFileExists(database_path('factories/UserFactory.php'));

    }
<?php             ->expectsOutput('2 factories created')

            ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertFileExists(database_path('factories/HabitFactory.php'));

    }
<?php             ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertFileExists(database_path('factories/HabitFactory.php'));

    }
<?php             ->expectsOutput('Factory blueprint created!')

            ->run();



        $this->assertFileExists(database_path('factories/HabitFactory.php'));

    }
<?php             ->expectsOutput('Factory blueprint created!')

            ->run();



        $this->assertFileExists(database_path('factories/HabitFactory.php'));

        $this->assertTrue(Str::contains(

            File::get(database_path('factories/HabitFactory.php')),

            "'user_id' => factory(Tests\Fixtures\Models\User::class)->lazy(),"
<?php         $this->assertFileExists(database_path('factories/HabitFactory.php'));

        $this->assertTrue(Str::contains(

            File::get(database_path('factories/HabitFactory.php')),

            "'user_id' => factory(Tests\Fixtures\Models\User::class)->lazy(),"

        ));

    }
<?php             ->expectsOutput('Factory blueprint created!')

            ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertTrue(Str::contains(

            File::get(database_path('factories/CarFactory.php')),

            "'owner_id' => factory(Tests\Fixtures\Models\User::class)->lazy(),"
<?php         $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertTrue(Str::contains(

            File::get(database_path('factories/CarFactory.php')),

            "'owner_id' => factory(Tests\Fixtures\Models\User::class)->lazy(),"

        ));

    }
<?php             ->expectsOutput('Factory created!')

            ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));



        $this->assertTrue(Str::contains(

            File::get(database_path('factories/CarFactory.php')),
<?php         $this->assertFileExists(database_path('factories/CarFactory.php'));



        $this->assertTrue(Str::contains(

            File::get(database_path('factories/CarFactory.php')),

            "'factory_year' => \$faker->randomNumber,"

        ));

    }
<?php             ->expectsOutput('Factory blueprint created!')

            ->run();



        $this->assertFileExists(database_path('factories/CarFactory.php'));

        $this->assertFalse(Str::contains(

            File::get(database_path('factories/CarFactory.php')),

            "'created_at' => \$faker,"