-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
273698c
commit f3b3914
Showing
10 changed files
with
179 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@extends($meta->template) | ||
|
||
@section('content') | ||
<x-spacing constrained> | ||
<x-page-header> | ||
<x-slot name="heading">Environment settings</x-slot> | ||
|
||
<x-slot name="actions"> | ||
<div x-data="{}"> | ||
<x-button x-on:click="$dispatch('toggle-spotlight')" color="neutral"> | ||
<x-icon name="search" size="sm"></x-icon> | ||
Find a setting | ||
</x-button> | ||
</div> | ||
</x-slot> | ||
</x-page-header> | ||
|
||
<x-form :action="route('settings.environment.update')" method="PUT"> | ||
<x-fieldset> | ||
<x-fieldset.field-group class="w-full max-w-md" x-data="{ environment: '{{ app()->environment() }}' }"> | ||
<x-fieldset.field label="Environment" id="environment" name="environment"> | ||
<x-select x-model="environment"> | ||
<option value="production">Production</option> | ||
<option value="local">Local</option> | ||
</x-select> | ||
|
||
<x-slot name="description"> | ||
<span x-show="environment === 'local'"> | ||
The local environment is intended only for development purposes. Some features may not | ||
work as expected when operating in this mode. | ||
</span> | ||
</x-slot> | ||
</x-fieldset.field> | ||
|
||
<x-switch.field> | ||
<x-fieldset.label for="debug_mode">Debug mode</x-fieldset.label> | ||
<x-fieldset.description> | ||
Enabling debug mode will allow informational messages, warnings, and errors to be displayed | ||
on screen. | ||
|
||
@if (config('app.debug')) | ||
<x-fieldset.error-message | ||
class="mt-2 font-semibold" | ||
x-show="environment === 'production'" | ||
x-cloak | ||
> | ||
In a production environment, debug mode should always be off. If debug mode is on in | ||
production, you risk exposing sensitive configuration values to your end users. | ||
</x-fieldset.error-message> | ||
@endif | ||
</x-fieldset.description> | ||
<x-switch | ||
id="debug_mode" | ||
name="debug_mode" | ||
:on-value="1" | ||
:off-value="0" | ||
:value="(int) config('app.debug')" | ||
></x-switch> | ||
</x-switch.field> | ||
|
||
<x-fieldset.field | ||
label="Site URL" | ||
description="Use caution when changing your site’s URL as it could have unintended side effects." | ||
id="url" | ||
name="url" | ||
> | ||
<x-input.text :value="config('app.url')" placeholder="Update your site URL"></x-input.text> | ||
</x-fieldset.field> | ||
</x-fieldset.field-group> | ||
</x-fieldset> | ||
|
||
<x-fieldset.controls> | ||
<x-button type="submit" color="primary">Update</x-button> | ||
</x-fieldset.controls> | ||
</x-form> | ||
</x-spacing> | ||
@endsection |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nova\Settings\Actions; | ||
|
||
use Exception; | ||
use Illuminate\Http\Request; | ||
use Lorisleiva\Actions\Concerns\AsAction; | ||
use Nova\Foundation\EnvWriter; | ||
use Nova\Settings\Data\EnvironmentConfiguration; | ||
|
||
class UpdateEnvironment | ||
{ | ||
use AsAction; | ||
|
||
public function handle(Request $request): void | ||
{ | ||
$envWriter = app(EnvWriter::class); | ||
|
||
if ($envWriter->isEnvWritable()) { | ||
$envConfigData = EnvironmentConfiguration::from($request); | ||
|
||
$path = $envWriter->envFilePath(); | ||
|
||
if (file_exists($path)) { | ||
$write = $envWriter->write([ | ||
'APP_ENV' => $envConfigData->environment, | ||
'APP_DEBUG' => $envConfigData->debugMode(), | ||
'APP_URL' => $envConfigData->url, | ||
]); | ||
|
||
if (! $write) { | ||
throw new Exception('error'); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
nova/src/Settings/Controllers/EnvironmentSettingsController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nova\Settings\Controllers; | ||
|
||
use Illuminate\Http\Request; | ||
use Nova\Foundation\Controllers\Controller; | ||
use Nova\Settings\Actions\UpdateEnvironment; | ||
use Nova\Settings\Responses\EnvironmentSettingsResponse; | ||
|
||
class EnvironmentSettingsController extends Controller | ||
{ | ||
public function __construct() | ||
{ | ||
parent::__construct(); | ||
|
||
$this->middleware('auth'); | ||
} | ||
|
||
public function edit() | ||
{ | ||
$this->authorize('update', $settings = settings()); | ||
|
||
return EnvironmentSettingsResponse::send(); | ||
} | ||
|
||
public function update(Request $request) | ||
{ | ||
$this->authorize('update', settings()); | ||
|
||
UpdateEnvironment::run($request); | ||
|
||
return redirect() | ||
->route('settings.environment.edit') | ||
->notify('Environment settings have been updated'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
nova/src/Settings/Responses/EnvironmentSettingsResponse.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nova\Settings\Responses; | ||
|
||
use Nova\Foundation\Responses\Responsable; | ||
|
||
class EnvironmentSettingsResponse extends Responsable | ||
{ | ||
public ?string $subnav = 'settings'; | ||
|
||
public string $view = 'settings.environment'; | ||
} |