Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanramsi committed Aug 15, 2023
1 parent fe4c192 commit b31ae8f
Show file tree
Hide file tree
Showing 18 changed files with 454 additions and 85 deletions.
4 changes: 3 additions & 1 deletion app/Livewire/Panel/Forms/Website/GeneralSettingForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use FilamentTiptapEditor\TiptapEditor;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;

class GeneralSettingForm extends Component implements HasForms
{
Expand All @@ -37,7 +39,7 @@ public function form(Form $form): Form
->collection('logo')
->image()
->conversion('thumb'),
RichEditor::make('meta.page_footer'),
TinyEditor::make('meta.page_footer'),

])
->statePath('data')
Expand Down
4 changes: 2 additions & 2 deletions app/Models/Conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class Conference extends Model implements HasMedia, HasName, HasAvatar
'type' => ConferenceType::class,
];

public static function current()
public static function current(): ?Conference
{
if (! isset(static::$current)) {
if (!isset(static::$current)) {
static::$current = static::where('is_current', true)->first();
}

Expand Down
10 changes: 9 additions & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

namespace App\Providers;

use App\Models\Conference;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
Expand All @@ -27,6 +29,7 @@ public function boot(): void
{
$this->setupModel();
$this->setupStorage();
$this->setupView();
}

protected function setupModel()
Expand All @@ -38,7 +41,7 @@ protected function setupModel()

// Since this is a performance concern only, don’t halt
// production for violations.
Model::preventLazyLoading(! $this->app->isProduction());
Model::preventLazyLoading(!$this->app->isProduction());
}

protected function setupMorph()
Expand Down Expand Up @@ -93,4 +96,9 @@ protected function setupStorage()
);
});
}

protected function setupView()
{
View::share('currentConference', Conference::current());
}
}
23 changes: 23 additions & 0 deletions app/Providers/Filament/PanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

use App\Http\Middleware\ApplyTenantScopes;
use App\Models\Conference;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\TimePicker;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
Expand Down Expand Up @@ -32,6 +35,8 @@ public function panel(Panel $panel): Panel
->id('panel')
->path('panel')
->maxContentWidth('full')
->homeUrl(fn () => route('livewirePageGroup.website.pages.home'))
->bootUsing(fn () => $this->setupFilamentComponent())
->renderHook(
'panels::scripts.before',
fn () => Blade::render(<<<'Blade'
Expand Down Expand Up @@ -119,4 +124,22 @@ protected function getAuthMiddleware(): array
Authenticate::class,
];
}

protected function setupFilamentComponent()
{
// TODO Validasi file type menggunakan dengan menggunakan format extension, bukan dengan mime type, hal ini agar mempermudah pengguna dalam melakukan setting file apa saja yang diperbolehkan
// Saat ini SpatieMediaLibraryFileUpload hanya support file validation dengan mime type.
// Solusi mungkin buat custom component upload dengan menggunakan library seperti dropzone, atau yang lainnya.
SpatieMediaLibraryFileUpload::configureUsing(function (SpatieMediaLibraryFileUpload $fileUpload): void {
$fileUpload->maxSize(config('media-library.max_file_size') / 1024);
// ->acceptedFileTypes(config('media-library.accepted_file_types'))
});
DatePicker::configureUsing(function (DatePicker $datePicker): void {
$datePicker->displayFormat(setting('format.date'));
});

TimePicker::configureUsing(function (TimePicker $timePicker): void {
$timePicker->displayFormat(setting('format.time'));
});
}
}
54 changes: 0 additions & 54 deletions app/Providers/FilamentServiceProvider.php

This file was deleted.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"require": {
"php": "^8.1",
"akaunting/laravel-setting": "^1.2",
"awcodes/filament-tiptap-editor": "^3.0@alpha",
"awcodes/filament-tiptap-editor": "^3.0@beta",
"binarytorch/larecipe": "^2.6",
"filament/filament": "^3.0",
"filament/spatie-laravel-media-library-plugin": "^3.0",
Expand All @@ -23,6 +23,7 @@
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"lorisleiva/laravel-actions": "^2.5",
"mohamedsabil83/filament-forms-tinyeditor": "^2.0",
"plank/laravel-metable": "^5.4",
"rahmanramsi/livewire-page-group": "^0.0.3",
"spatie/eloquent-sortable": "^4.0",
Expand Down
86 changes: 84 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@
// App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\FilamentServiceProvider::class,
App\Providers\Filament\PanelProvider::class,
App\Providers\WebsiteServiceProvider::class,

Expand Down
89 changes: 89 additions & 0 deletions config/filament-forms-tinyeditor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

return [
/*
|--------------------------------------------------------------------------
| Profiles
|--------------------------------------------------------------------------
|
| You can add as many as you want of profiles to use it in your application.
|
*/

'profiles' => [

'default' => [
'plugins' => 'advlist autoresize codesample directionality emoticons fullscreen hr image imagetools link lists media table toc wordcount code',
'toolbar' => 'undo redo removeformat | formatselect fontsizeselect | bold italic | rtl ltr | alignjustify alignright aligncenter alignleft | numlist bullist | forecolor backcolor | blockquote table hr | image link code | fullscreen',
'upload_directory' => 'tinyeditor',
],

'simple' => [
'plugins' => 'autoresize directionality emoticons link wordcount',
'toolbar' => 'removeformat | bold italic | rtl ltr | link emoticons',
'upload_directory' => null,
],

'template' => [
'plugins' => 'autoresize template',
'toolbar' => 'template',
'upload_directory' => null,
],
/*
|--------------------------------------------------------------------------
| Custom Configs
|--------------------------------------------------------------------------
|
| If you want to add custom configurations to directly tinymce
| You can use custom_configs key as an array
|
*/

/*
'default' => [
'plugins' => 'advlist autoresize codesample directionality emoticons fullscreen hr image imagetools link lists media table toc wordcount',
'toolbar' => 'undo redo removeformat | formatselect fontsizeselect | bold italic | rtl ltr | alignjustify alignright aligncenter alignleft | numlist bullist | forecolor backcolor | blockquote table toc hr | image link media codesample emoticons | wordcount fullscreen',
'custom_configs' => [
'allow_html_in_named_anchor' => true,
'link_default_target' => '_blank',
'codesample_global_prismjs' => true,
'image_advtab' => true,
'image_class_list' => [
[
'title' => 'None',
'value' => '',
],
[
'title' => 'Fluid',
'value' => 'img-fluid',
],
],
]
],
*/

],

/*
|--------------------------------------------------------------------------
| Templates
|--------------------------------------------------------------------------
|
| You can add as many as you want of templates to use it in your application.
|
| https://www.tiny.cloud/docs/plugins/opensource/template/#templates
|
| ex: TinyEditor::make('content')->profiles('template')->template('example')
*/

'templates' => [

'example' => [
// content
['title' => 'Some title 1', 'description' => 'Some desc 1', 'content' => 'My content'],
// url
['title' => 'Some title 2', 'description' => 'Some desc 2', 'url' => 'http://localhost'],
],

],
];
2 changes: 1 addition & 1 deletion packages/livewire-page-group
Submodule livewire-page-group updated from 584c8a to 0f57f8
Loading

0 comments on commit b31ae8f

Please sign in to comment.