Skip to content

Commit

Permalink
Merge pull request #17 from lara-zeus/validation
Browse files Browse the repository at this point in the history
add some validation
  • Loading branch information
atmonshi committed Jul 6, 2023
2 parents 2085261 + 43123c6 commit 739aeb2
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 64 deletions.
10 changes: 5 additions & 5 deletions composer.lock

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

24 changes: 13 additions & 11 deletions resources/views/themes/zeus/widgets/FaqWidget.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@
Special Thanks and Love to Ildiko Gaspar
-->
@foreach($data['faqs'] as $faq)
<div class="transition rounded-xl hover:bg-gray-100 bg-gray-50">
<div class="accordion-header cursor-pointer transition flex space-x-5 px-5 items-center h-16">
<x-heroicon-o-chevron-down class="w-5 h-5 text-secondary-600"/>
<h3 class="font-semibold">{{ $faq->question }}</h3>
</div>
<div class="accordion-content overflow-hidden max-h-0">
<div class="bg-white border border-gray-200 rounded-xl rounded-t-none leading-6 font-light text-justify p-4">
{!! $faq->answer !!}
@if($data['faqs'] !== null)
@foreach($data['faqs'] as $faq)
<div class="transition rounded-xl hover:bg-gray-100 bg-gray-50">
<div class="accordion-header cursor-pointer transition flex space-x-5 px-5 items-center h-16">
<x-heroicon-o-chevron-down class="w-5 h-5 text-secondary-600"/>
<h3 class="font-semibold">{{ $faq->question }}</h3>
</div>
<div class="accordion-content overflow-hidden max-h-0">
<div class="bg-white border border-gray-200 rounded-xl rounded-t-none leading-6 font-light text-justify p-4">
{!! $faq->answer !!}
</div>
</div>
</div>
</div>
@endforeach
@endforeach
@endif

<style>
.accordion-content {
Expand Down
4 changes: 3 additions & 1 deletion resources/views/themes/zeus/widgets/FormsWidget.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<div>
<livewire:bolt.fill-form :slug="$data['form_slug']" />
@if($data['form_slug'] !== null)
<livewire:bolt.fill-form :slug="$data['form_slug']" />
@endif
</div>
34 changes: 18 additions & 16 deletions resources/views/themes/zeus/widgets/LibraryWidget.blade.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<div>
@foreach($data['library'] as $library)
<a href="{{ route('library.item', ['slug' => $library->slug]) }}" class="flex flex-col py-2 px-1.5 hover:bg-gray-100 dark:hover:bg-gray-600 rounded-md transition ease-in-out duration-500 block cursor-pointer">
<div x-data class="flex items-center justify-between text-primary-600 dark:text-primary-400 hover:dark:text-primary-300">
<h3>{{ $library->title ?? '' }}</h3>
@if($library->type === 'IMAGE')
@if($data['library'] !== null)
@foreach($data['library'] as $library)
<a href="{{ route('library.item', ['slug' => $library->slug]) }}" class="flex flex-col py-2 px-1.5 hover:bg-gray-100 dark:hover:bg-gray-600 rounded-md transition ease-in-out duration-500 block cursor-pointer">
<div x-data class="flex items-center justify-between text-primary-600 dark:text-primary-400 hover:dark:text-primary-300">
<h3>{{ $library->title ?? '' }}</h3>
@if($library->type === 'IMAGE')
<x-heroicon-o-photograph x-tooltip.raw="{{ __('Image') }}" class="w-4 h-4 text-gray-400 dark:text-gray-500" />
@endif
@endif

@if($library->type === 'FILE')
@if($library->type === 'FILE')
<x-heroicon-o-document x-tooltip.raw="{{ __('File') }}" class="w-4 h-4 text-gray-400 dark:text-gray-500" />
@endif
@endif

@if($library->type === 'VIDEO')
@if($library->type === 'VIDEO')
<x-heroicon-o-film x-tooltip.raw="{{ __('Video') }}" class="w-4 h-4 text-gray-400 dark:text-gray-500" />
@endif
</div>
<cite class="text-sm text-secondary-600 dark:text-secondary-500 hover:dark:text-secondary-300">
{{ $library->description }}
</cite>
</a>
@endforeach
@endif
</div>
<cite class="text-sm text-secondary-600 dark:text-secondary-500 hover:dark:text-secondary-300">
{{ $library->description }}
</cite>
</a>
@endforeach
@endif
</div>
56 changes: 29 additions & 27 deletions resources/views/themes/zeus/widgets/MenuWidget.blade.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
<div>
@php
$nav = $data['menu']->items;
@endphp
@if($nav !== null)
@if($data['menu_dir'] === 'vertical')
<nav class="px-2 flex flex-1 flex-col" aria-label="Sidebar">
<ul role="list" class="-mx-2 space-y-1">
@if($data['menu'] !== null)
@php
$nav = $data['menu']->items;
@endphp
@if($nav !== null)
@if($data['menu_dir'] === 'vertical')
<nav class="px-2 flex flex-1 flex-col" aria-label="Sidebar">
<ul role="list" class="-mx-2 space-y-1">
@foreach($nav as $item)
<li>
{!! \LaraZeus\Sky\Classes\RenderNavItem::render($item,'text-gray-700 hover:text-secondary-600 hover:bg-secondary-50 group flex gap-x-3 rounded-3xl p-2 pl-3 text-sm transition-all ease-in-out duration-300') !!}
</li>
@endforeach
</ul>
</nav>
@else
<div class="container mx-auto flex items-center justify-center">
@foreach($nav as $item)
<li>
{!! \LaraZeus\Sky\Classes\RenderNavItem::render($item,'text-gray-700 hover:text-secondary-600 hover:bg-secondary-50 group flex gap-x-3 rounded-3xl p-2 pl-3 text-sm transition-all ease-in-out duration-300') !!}
</li>
@if(!empty($item['children']))
<button class="flex items-center justify-center gap-1 text-sm text-primary-500 focus:outline-none transition-all ease-in-out duration-300">
{{ $item['label'] }}
</button>
@foreach($item['children'] as $children)
{!! \LaraZeus\Sky\Classes\RenderNavItem::render($children,'block px-4 py-2 text-sm leading-5 text-primary-500 hover:bg-secondary-100 focus:outline-none focus:bg-gray-100 transition-all ease-in-out duration-300') !!}
@endforeach
@else
{!! \LaraZeus\Sky\Classes\RenderNavItem::render($item,'px-5 py-2 text-base font-medium text-primary-500 hover:text-secondary-800 transition-all ease-in-out duration-300') !!}
@endif
@endforeach
</ul>
</nav>
@else
<div class="container mx-auto flex items-center justify-center">
@foreach($nav as $item)
@if(!empty($item['children']))
<button class="flex items-center justify-center gap-1 text-sm text-primary-500 focus:outline-none transition-all ease-in-out duration-300">
{{ $item['label'] }}
</button>
@foreach($item['children'] as $children)
{!! \LaraZeus\Sky\Classes\RenderNavItem::render($children,'block px-4 py-2 text-sm leading-5 text-primary-500 hover:bg-secondary-100 focus:outline-none focus:bg-gray-100 transition-all ease-in-out duration-300') !!}
@endforeach
@else
{!! \LaraZeus\Sky\Classes\RenderNavItem::render($item,'px-5 py-2 text-base font-medium text-primary-500 hover:text-secondary-800 transition-all ease-in-out duration-300') !!}
@endif
@endforeach
</div>
</div>
@endif
@endif
@endif
</div>
3 changes: 2 additions & 1 deletion src/Widgets/Classes/FaqWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function form(): Builder\Block
->label(__('Faq'))
->schema([
Select::make('faq_cat')
->required()
->options(
config('zeus-sky.models.tag')::query()
->where('type', 'faq')
Expand All @@ -40,7 +41,7 @@ public function form(): Builder\Block
public function viewData(array $data): array
{
return [
'faqs' => config('zeus-sky.models.faq')::withAnyTags([$data['faq_cat']], 'faq')->get(),
'faqs' => ($data['faq_cat'] !== null) ? config('zeus-sky.models.faq')::withAnyTags([$data['faq_cat']], 'faq')->get() : null,
];
}
}
1 change: 1 addition & 0 deletions src/Widgets/Classes/FormsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function form(): Builder\Block
->label(__('Forms'))
->schema([
Select::make('form_slug')
->required()
->options(
config('zeus-bolt.models.Form')::pluck('name', 'slug')
),
Expand Down
3 changes: 2 additions & 1 deletion src/Widgets/Classes/LibraryWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function form(): Builder\Block
->label(__('Library'))
->schema([
Select::make('library_slug')
->required()
->options(
config('zeus-sky.models.tag')::query()
->where('type', 'library')
Expand All @@ -40,7 +41,7 @@ public function form(): Builder\Block
public function viewData(array $data): array
{
return [
'library' => config('zeus-sky.models.library')::withAnyTags([$data['library_slug']], 'library')->get(),
'library' => ($data['library_slug'] !== null) ? config('zeus-sky.models.library')::withAnyTags([$data['library_slug']], 'library')->get() : null,
];
}
}
4 changes: 3 additions & 1 deletion src/Widgets/Classes/MenuWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ public function form(): Builder\Block
->label(__('Menu'))
->schema([
Select::make('menu_slug')
->required()
->options(
// @phpstan-ignore-next-line
\RyanChandler\FilamentNavigation\Models\Navigation::pluck('name', 'handle')
),
Select::make('menu_dir')
->default('vertical')
->options([
'vertical' => __('vertical'),
'horizontal' => __('horizontal'),
Expand All @@ -44,7 +46,7 @@ public function viewData(array $data): array
{
return [
// @phpstan-ignore-next-line
'menu' => \RyanChandler\FilamentNavigation\Facades\FilamentNavigation::get($data['menu_slug']),
'menu' => ($data['menu_slug'] !== null) ? \RyanChandler\FilamentNavigation\Facades\FilamentNavigation::get($data['menu_slug']) : null,
];
}
}
4 changes: 3 additions & 1 deletion src/Widgets/Classes/PostsWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function form(): Builder\Block
Tabs\Tab::make('posts')
->label(__('Posts'))
->schema([
TextInput::make('limit')->numeric()->default(5),
TextInput::make('limit')
->numeric()
->default(5),
Select::make('orderBy')
->options([
'id' => __('id'),
Expand Down

0 comments on commit 739aeb2

Please sign in to comment.