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 'sqlite' => [
'driver' => 'sqlite',
'url' => env('DB_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
<?php if ($this->option('prune')) {
(new Filesystem)->deleteDirectory(
database_path('migrations'), $preserve = false
);
$info .= ' and pruned';
<?php protected function path(Connection $connection)
{
return tap($this->option('path') ?: database_path('schema/'.$connection->getName().'-schema.sql'), function ($path) {
(new Filesystem)->ensureDirectoryExists(dirname($path));
});
}
<?php return $this->option('schema-path');
}
if (file_exists($path = database_path('schema/'.$connection->getName().'-schema.dump'))) {
return $path;
}
<?php return $path;
}
return database_path('schema/'.$connection->getName().'-schema.sql');
}
}
<?php {
$from = __DIR__.'/stubs/auth/statamic_auth_tables.php.stub';
$file = date('Y_m_d_His', time()).'_statamic_auth_tables';
$to = database_path("migrations/{$file}.php");
$contents = File::get($from);
<?php public function handle()
{
File::put(
database_path().'/migrations/'.date('Y_m_d_His').'_create_users_tables.php',
File::get(__DIR__.'/stubs/create_users_tables.php.stub')
);
}
<?php 'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
<?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'));
}