Hardik Thakker 30a7e70cb9
Using Prefix from ENV variable during installation
- Currently, during installation, we do not take into account the database table name prefix from env variables during installation (if specified by the user we ignore it and we try to generate a random prefix)
- For me putting that auto-generated random prefix back into environment variables failed after install, causing the installation to die, so I added it in env variables before hand, but that didn't help as we were ignoring it.
2023-06-24 12:57:39 +05:30

58 lines
1.5 KiB
PHP

<?php
namespace App\Http\Controllers\Install;
use App\Http\Requests\Install\Database as Request;
use App\Utilities\Installer;
use Illuminate\Routing\Controller;
class Database extends Controller
{
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
return view('install.database.create');
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
*
* @return Response
*/
public function store(Request $request)
{
$connection = config('database.default','mysql');
$host = $request['hostname'];
$port = config("database.connections.$connection.port", '3306');
$database = $request['database'];
$username = $request['username'];
$password = $request['password'];
$prefix = config("database.connections.$connection.prefix", null);
// Check database connection
if (!Installer::createDbTables($host, $port, $database, $username, $password, $prefix)) {
$response = [
'status' => null,
'success' => false,
'error' => true,
'message' => trans('install.error.connection'),
'data' => null,
'redirect' => null,
];
}
if (empty($response)) {
$response['redirect'] = route('install.settings');
}
return response()->json($response);
}
}