fixes and stuff

This commit is contained in:
2024-09-11 16:21:51 +03:00
parent 8ac0567e66
commit f868219981
10 changed files with 141 additions and 115 deletions
+9
View File
@@ -16,6 +16,15 @@ class SetupDatabase extends Command
public function handle()
{
$dbConnection = config("lucent.database");
$databasePath = config("database.connections.$dbConnection.database");
if(file_exists($databasePath)){
$this->error("Database already exists.");
return 0;
}
touch($databasePath);
$this->tableUsers();
$this->tableRecords();
$this->tableRevisions();
+1 -1
View File
@@ -2,7 +2,7 @@
return [
"env" => env("LUCENT_ENV", "production"),
"schemas_path" => env("LUCENT_SCHEMAS_PATH", "app/Lucent"),
"schemas_path" => env("LUCENT_SCHEMAS_PATH", "resources/lucent/schemas"),
"database" => env('LUCENT_DB_CONNECTION', env('DB_CONNECTION', "sqlite")),
"name" => env("LUCENT_NAME", "Lucent"),
"url" => env("LUCENT_URL", env('APP_URL')),
+1
View File
@@ -9,6 +9,7 @@ class Database
{
public static function make(): Connection{
$dbConnection = config("lucent.database");
return DB::connection($dbConnection);
}
-1
View File
@@ -39,7 +39,6 @@ class FileController extends Controller
$validator = Validator::make($request->all(), [
'files.*' => 'required|file|max:100000',
]);
if ($validator->fails()) {
return fail($validator->errors()->first());
}
+10
View File
@@ -17,7 +17,9 @@ class DatabaseSetupStep implements IStep
$databaseConnectionName = config("lucent.database");
$databaseConfig = config('database.connections.'.$databaseConnectionName);
if (empty($databaseConfig)) {
$instructions = <<<EOD
# You need to setup a database connection for $databaseConnectionName in database.php config. You can choose either sqlite or pgsql
@@ -35,6 +37,14 @@ EOD;
return SetupStep::makeFail($name, $instructions);
}
if(!in_array($driver = $databaseConfig["driver"],["sqlite","pgsql"])){
$instructions = <<<EOD
You can choose either sqlite or pgsql. You current config is: $driver
EOD;
return SetupStep::makeFail($name, $instructions);
}
try {
Database::make()->table("records")->get();
} catch (QueryException $e) {