Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanramsi committed Aug 23, 2023
1 parent f80a337 commit 635cc4d
Show file tree
Hide file tree
Showing 37 changed files with 1,435 additions and 304 deletions.
23 changes: 3 additions & 20 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
Expand Down Expand Up @@ -37,25 +36,9 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="[email protected]"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"




# Files
MAX_FILE_UPLOAD_SIZE = 5
Expand Down
39 changes: 39 additions & 0 deletions app/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace App;

use Illuminate\Foundation\Application as LaravelApplication;

class Application extends LaravelApplication{

public const APP_VERSION = '1.0.0';

public const PHP_MIN_VERSION = '8.1';

public function isInstalled(){
return file_exists(storage_path('installed'));
}

public function getAppVersion()
{
return static::APP_VERSION;
}

public function getPhpMinVersion()
{
return static::PHP_MIN_VERSION;
}

public function getRequiredPhpExtensions()
{
return [
'openssl',
'pdo',
'mbstring',
'tokenizer',
'xml',
];
}


}
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http;

use App\Http\Middleware\InstallationMiddleware;
use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
Expand Down Expand Up @@ -36,6 +37,7 @@ class Kernel extends HttpKernel
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
InstallationMiddleware::class,
],

'api' => [
Expand Down
36 changes: 36 additions & 0 deletions app/Http/Middleware/InstallationMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace App\Http\Middleware;

use App\Website\Pages\Installation;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Symfony\Component\HttpFoundation\Response;

class InstallationMiddleware
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{

// Allow livewire update route
if (Route::getCurrentRoute()->uri === 'livewire/update') {
return $next($request);
}

$installationPage = Installation::getSlug();


if (!app()->isInstalled() && Route::getCurrentRoute()->uri !== $installationPage) {
return redirect($installationPage);
}


return $next($request);
}
}
5 changes: 3 additions & 2 deletions app/Infolists/Components/LivewireEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public static function make(string $name, string $component = null, array $viewD

public function toHtml(): string
{
return Blade::render('@livewire($component, $viewData)', [
return Blade::render('@livewire($component, $viewData, key($key))', [
'component' => $this->getState(),
'viewData' => $this->viewData,
'key' => 'data'
]);
}

Expand All @@ -37,7 +38,7 @@ public function livewire(?string $component, array $viewData = [])

public function lazy(bool $lazy = true)
{
$this->viewData(['lazy' => $lazy]);
$this->viewData(['lazy' => $lazy,]);

return $this;
}
Expand Down
45 changes: 45 additions & 0 deletions app/Livewire/Forms/Installation/AccountForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace App\Livewire\Forms\Installation;

use App\Actions\User\UserCreateAction;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Livewire\Attributes\Rule;
use Livewire\Form;

class AccountForm extends Form
{
#[Rule('required')]
public $given_name = 'Rahman';

#[Rule('required')]
public $family_name = 'Ramsi';

#[Rule('required|email')]
public $email = '[email protected]';

#[Rule('required|confirmed')]
public $password = 'password';

#[Rule('required')]
public $password_confirmation = 'password';

public function createAccount()
{
try {
DB::beginTransaction();
dd($this->only(['email']));
User::updateOrCreate(
$this->only(['given_name', 'family_name', 'password']),
$this->only(['email']),
);

DB::commit();
} catch (\Throwable $th) {
DB::rollBack();

throw $th;
}
}
}
15 changes: 15 additions & 0 deletions app/Livewire/Forms/Installation/ConferenceForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Livewire\Forms\Installation;

use Livewire\Attributes\Rule;
use Livewire\Form;

class ConferenceForm extends Form
{
#[Rule('required')]
public $name = null;

#[Rule('required')]
public $type = 'Offline';
}
87 changes: 87 additions & 0 deletions app/Livewire/Forms/Installation/DatabaseForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

namespace App\Livewire\Forms\Installation;

use App\Utils\EnvironmentManager;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\ValidationException;
use Livewire\Attributes\Rule;
use Livewire\Form;

class DatabaseForm extends Form
{
#[Rule('required')]
public $connection = 'mysql';

#[Rule('required')]
public $username = 'root_db';

#[Rule('required')]
public $password = 'password';

#[Rule('required')]
public $name = 'conf';

#[Rule('required')]
public $host = '127.0.0.1';

#[Rule('required')]
public $port = '3306';


public function checkConnection()
{
$connection = $this->connection;

$settings = config("database.connections.$connection");

$connectionArray = array_merge($settings, [
'driver' => $connection,
'database' => $this->name,
]);

if (!empty($this->username) && !empty($this->password)) {
$connectionArray = array_merge($connectionArray, [
'username' => $this->username,
'password' => $this->password,
'host' => $this->host,
'port' => $this->port,
]);
}


Config::set("database.connections.$connection", $connectionArray);

try {
// reconnect to database with new settings
DB::reconnect();
return DB::connection()->getPdo();
} catch (\Throwable $th) {
$this->addError('checkConnection', $th->getMessage());

return false;
}

}

public function migrate()
{
Artisan::call('optimize:clear');

if (app(EnvironmentManager::class)->writeEnvWithCurrentConfiguration()) {
Artisan::call('key:generate --force');
Artisan::call('optimize:clear');
Artisan::call('storage:link');
Artisan::call('migrate:fresh --force --seed');
}
}

public function process()
{
if(!$this->checkConnection()) return false;

$this->migrate();
}
}
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{
//

}

/**
Expand Down
15 changes: 8 additions & 7 deletions app/Providers/Filament/PanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ protected function getWidgets(): array
protected function getMiddleware(): array
{
return [
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
// EncryptCookies::class,
// AddQueuedCookiesToResponse::class,
// StartSession::class,
// AuthenticateSession::class,
// ShareErrorsFromSession::class,
// VerifyCsrfToken::class,
// SubstituteBindings::class,
'web',
DisableBladeIconComponents::class,
DispatchServingFilamentEvent::class,
];
Expand Down
15 changes: 2 additions & 13 deletions app/Providers/WebsiteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
use App\Http\Middleware\VerifyCsrfToken;
use App\Http\Middleware\Website\ApplyCurrentConference;
use App\Website\Pages\Home;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\Support\Facades\Blade;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Rahmanramsi\LivewirePageGroup\PageGroup;
use Rahmanramsi\LivewirePageGroup\PageGroupServiceProvider;

Expand All @@ -22,16 +17,10 @@ public function pageGroup(PageGroup $pageGroup): PageGroup
return $pageGroup
->id('website')
->path('')
->layout('website.layouts.app')
->layout('website.components.layouts.app')
->homePage(Home::class)
->middleware([
EncryptCookies::class,
AddQueuedCookiesToResponse::class,
StartSession::class,
AuthenticateSession::class,
ShareErrorsFromSession::class,
VerifyCsrfToken::class,
SubstituteBindings::class,
'web',
ApplyCurrentConference::class,
], true)
->discoverPages(in: app_path('Website/Pages'), for: 'App\\Website\\Pages');
Expand Down
Loading

0 comments on commit 635cc4d

Please sign in to comment.