-
Notifications
You must be signed in to change notification settings - Fork 1
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
dc9b91c
commit 9cca8f1
Showing
23 changed files
with
396 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Actions\Settings; | ||
|
||
use Lorisleiva\Actions\Concerns\AsAction; | ||
|
||
class SettingPopulateDefaultData | ||
{ | ||
use AsAction; | ||
|
||
public function handle() | ||
{ | ||
// ... | ||
} | ||
} |
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,91 @@ | ||
<?php | ||
|
||
namespace App\Administration\Livewire; | ||
|
||
use App\Actions\MailTemplates\MailTemplatePopulateDefaultData; | ||
use App\Actions\MailTemplates\MailTemplateRestoreDefaultData; | ||
use App\Actions\Settings\SettingUpdateAction; | ||
use App\Infolists\Components\BladeEntry; | ||
use App\Infolists\Components\VerticalTabs; | ||
use App\Mail\Templates\TestMail; | ||
use App\Mail\Templates\VerifyUserEmail; | ||
use App\Models\MailTemplate; | ||
use Filament\Forms\Components\Actions; | ||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Forms\Components\Checkbox; | ||
use Filament\Forms\Components\Section; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Concerns\InteractsWithForms; | ||
use Filament\Forms\Contracts\HasForms; | ||
use Filament\Forms\Form; | ||
use Filament\Infolists\Concerns\InteractsWithInfolists; | ||
use Filament\Infolists\Contracts\HasInfolists; | ||
use Filament\Infolists\Infolist; | ||
use Filament\Notifications\Notification; | ||
use Filament\Support\Enums\FontWeight; | ||
use Filament\Tables\Actions\Action as TableAction; | ||
use Filament\Tables\Actions\ActionGroup; | ||
use Filament\Tables\Actions\EditAction; | ||
use Filament\Tables\Columns\Layout\Split; | ||
use Filament\Tables\Columns\Layout\Stack; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Columns\TextColumn\TextColumnSize; | ||
use Filament\Tables\Concerns\InteractsWithTable; | ||
use Filament\Tables\Contracts\HasTable; | ||
use Filament\Tables\Table; | ||
use Illuminate\Support\Facades\Mail; | ||
use Illuminate\Support\Str; | ||
use Livewire\Component; | ||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor; | ||
|
||
class AccessSetting extends Component implements HasForms | ||
{ | ||
use InteractsWithForms; | ||
|
||
public ?array $formData = []; | ||
|
||
public function mount() | ||
{ | ||
$this->form->fill(setting()->all()); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Section::make() | ||
->schema([ | ||
Checkbox::make('allow_registration') | ||
->label('Allow Registration') | ||
->helperText('Allow public to register on the site.'), | ||
Checkbox::make('must_verify_email') | ||
->label('Must Verify Email') | ||
->helperText('Require users to verify their email address before they can log in.'), | ||
]) | ||
->columns(1), | ||
Actions::make([ | ||
Action::make('save') | ||
->label('Save') | ||
->successNotificationTitle('Saved!') | ||
->failureNotificationTitle('Data could not be saved.') | ||
->action(function (Action $action) { | ||
$formData = $this->form->getState(); | ||
try { | ||
SettingUpdateAction::run($formData); | ||
$action->sendSuccessNotification(); | ||
} catch (\Throwable $th) { | ||
$action->failure(); | ||
// $action->sendFailureNotification(); | ||
} | ||
}), | ||
])->alignLeft(), | ||
]) | ||
->statePath('formData'); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('administration.livewire.access-setting'); | ||
} | ||
} |
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,104 @@ | ||
<?php | ||
|
||
namespace App\Administration\Livewire; | ||
|
||
use App\Actions\MailTemplates\MailTemplatePopulateDefaultData; | ||
use App\Actions\MailTemplates\MailTemplateRestoreDefaultData; | ||
use App\Actions\Settings\SettingUpdateAction; | ||
use App\Infolists\Components\BladeEntry; | ||
use App\Infolists\Components\VerticalTabs; | ||
use App\Mail\Templates\TestMail; | ||
use App\Mail\Templates\VerifyUserEmail; | ||
use App\Models\MailTemplate; | ||
use Filament\Forms\Components\Actions; | ||
use Filament\Forms\Components\Actions\Action; | ||
use Filament\Forms\Components\Checkbox; | ||
use Filament\Forms\Components\Radio; | ||
use Filament\Forms\Components\Section; | ||
use Filament\Forms\Components\Select; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Forms\Concerns\InteractsWithForms; | ||
use Filament\Forms\Contracts\HasForms; | ||
use Filament\Forms\Form; | ||
use Filament\Infolists\Concerns\InteractsWithInfolists; | ||
use Filament\Infolists\Contracts\HasInfolists; | ||
use Filament\Infolists\Infolist; | ||
use Filament\Notifications\Notification; | ||
use Filament\Support\Enums\FontWeight; | ||
use Filament\Tables\Actions\Action as TableAction; | ||
use Filament\Tables\Actions\ActionGroup; | ||
use Filament\Tables\Actions\EditAction; | ||
use Filament\Tables\Columns\Layout\Split; | ||
use Filament\Tables\Columns\Layout\Stack; | ||
use Filament\Tables\Columns\TextColumn; | ||
use Filament\Tables\Columns\TextColumn\TextColumnSize; | ||
use Filament\Tables\Concerns\InteractsWithTable; | ||
use Filament\Tables\Contracts\HasTable; | ||
use Filament\Tables\Table; | ||
use Illuminate\Support\Facades\Mail; | ||
use Illuminate\Support\HtmlString; | ||
use Illuminate\Support\Str; | ||
use Livewire\Component; | ||
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor; | ||
|
||
class DateAndTimeSetting extends Component implements HasForms | ||
{ | ||
use InteractsWithForms; | ||
|
||
public ?array $formData = []; | ||
|
||
public function mount() | ||
{ | ||
$this->form->fill(setting()->all()); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
$now = now()->hours(16); | ||
|
||
return $form | ||
->statePath('formData') | ||
->schema([ | ||
Section::make('Date and Time Formats') | ||
->description(new HtmlString(<<<'HTML' | ||
Please select the desired format for dates and times. You may also enter a custom format using | ||
special <a href="https://www.php.net/manual/en/function.strftime.php#refsect1-function.strftime-parameters" target="_blank" | ||
class="filament-link inline-flex items-center justify-center gap-0.5 font-medium outline-none hover:underline focus:underline text-sm text-primary-600 hover:text-primary-500 filament-tables-link-action">format characters</a>. | ||
HTML)) | ||
->schema([ | ||
Radio::make('format.date') | ||
->options(fn () => collect([ | ||
'F j, Y', | ||
'F j Y', | ||
'j F Y', | ||
'Y F j', | ||
])->mapWithKeys(fn ($format) => [$format => $now->format($format)])), | ||
Radio::make('format.time') | ||
->options(fn () => collect([ | ||
'h:i A', | ||
'g:ia', | ||
'H:i', | ||
])->mapWithKeys(fn ($format) => [$format => $now->format($format)])), | ||
]), | ||
Actions::make([ | ||
Action::make('save') | ||
->successNotificationTitle('Saved!') | ||
->action(function (Action $action) { | ||
$formData = $this->form->getState(); | ||
try { | ||
SettingUpdateAction::run($formData); | ||
|
||
$action->sendSuccessNotification(); | ||
} catch (\Throwable $th) { | ||
$action->sendFailureNotification(); | ||
} | ||
}), | ||
])->alignLeft(), | ||
]); | ||
} | ||
|
||
public function render() | ||
{ | ||
return view('administration.livewire.access-setting'); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class MustVerifyEmail | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next | ||
*/ | ||
public function handle(Request $request, Closure $next): Response | ||
{ | ||
if(!setting('must_verify_email')){ | ||
return $next($request); | ||
} | ||
|
||
if(!$request->user()){ | ||
return redirect()->route('livewirePageGroup.website.pages.login'); | ||
} | ||
|
||
if(!$request->user()->hasVerifiedEmail()){ | ||
return redirect()->route('livewirePageGroup.website.pages.email-verification'); | ||
} | ||
|
||
|
||
return $next($request); | ||
} | ||
} |
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
Oops, something went wrong.