Skip to content

Commit 0a8bce6

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 6d4e62e + 2788efd commit 0a8bce6

File tree

4 files changed

+92
-3
lines changed

4 files changed

+92
-3
lines changed

docs/basic-usage/conditional-wrapper.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,15 @@ In the example below, sections are conditionally shown or hidden based on the st
6464
- `data-hide-fields="true"`: Hides all form fields within the section instead of removing the entire section.
6565
- `data-disable="true"`: Inverts the logic—disables or hides the section when the checkbox is checked.
6666

67+
68+
### Updated Blade syntax for using the conditional wrapper using Checkbox
69+
```html
70+
<x-forms::conditional-wrapper enable-elem="#online_interview" :enable-value="1" enable-checkbox hide-fields >
71+
This section is displayed only when the checkbox is checked
72+
</x-forms::conditional-wrapper>
73+
74+
<x-forms::conditional-wrapper enable-elem="#online_interview" :enable-value="1" enable-checkbox hide-fields disable >
75+
This section is HIDDEN when the checkbox is checked
76+
</x-forms::conditional-wrapper>
77+
78+
```

resources/views/bootstrap-5/no-items.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<div class="container mt-5">
22
<div class="row justify-content-center">
33
<div class="col-md-6">
4-
<div class="card">
5-
<div class="card-body text-center">
4+
<x-forms::card>
5+
<div class="text-center">
66
<i class="{{ $icon }} main-icon mb-4"></i>
77
<p class="lead mb-4">
88
@if($title){{ $title }} <br/> @endif
@@ -18,7 +18,7 @@
1818
@endif
1919
@endif
2020
</div>
21-
</div>
21+
</x-forms::card>
2222
</div>
2323
</div>
2424
</div>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Javaabu\Forms\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Filesystem\Filesystem;
7+
use Symfony\Component\Finder\Finder;
8+
use function Laravel\Prompts\multisearch;
9+
use function Laravel\Prompts\confirm;
10+
11+
class PublishViewCommand extends Command
12+
{
13+
protected $signature = 'forms:publish-view';
14+
protected $description = 'Interactively publish one or more form view files to your application for customization.';
15+
16+
public function handle()
17+
{
18+
$sourcePath = __DIR__ . '/../../resources/views';
19+
$targetBase = base_path('resources/views/vendor/forms');
20+
$filesystem = new Filesystem();
21+
$finder = new Finder();
22+
$finder->files()->in($sourcePath);
23+
24+
$files = [];
25+
$options = [];
26+
foreach ($finder as $file) {
27+
$relativePath = $file->getRelativePathname();
28+
$files[$relativePath] = $file->getRealPath();
29+
$targetPath = $targetBase . '/' . $relativePath;
30+
$label = $relativePath . ($filesystem->exists($targetPath) ? ' (published)' : '');
31+
$options[$relativePath] = $label;
32+
}
33+
34+
if (empty($files)) {
35+
$this->error('No view files found to publish.');
36+
return 1;
37+
}
38+
39+
$selected = multisearch(
40+
label: 'Search and select view files to publish:',
41+
options: fn ($search) => array_filter(
42+
$options,
43+
fn ($label) => stripos($label, $search) !== false
44+
),
45+
required: 'You must select at least one file to publish.'
46+
);
47+
48+
foreach ($selected as $relativePath) {
49+
$target = $targetBase . '/' . $relativePath;
50+
$filesystem->ensureDirectoryExists(dirname($target));
51+
if ($filesystem->exists($target)) {
52+
if (!confirm(
53+
label: "{$relativePath} already exists. Overwrite?",
54+
default: false,
55+
yes: 'Overwrite',
56+
no: 'Skip',
57+
hint: 'If you skip, the existing file will be kept.'
58+
)) {
59+
$this->line("Skipped: {$relativePath}");
60+
continue;
61+
}
62+
}
63+
$filesystem->copy($files[$relativePath], $target);
64+
$this->info("Published: {$relativePath}");
65+
}
66+
67+
$this->info('Selected view files published successfully.');
68+
return 0;
69+
}
70+
}

src/FormsServiceProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,12 @@ public function register(): void
5656
$this->app->singleton(FormsDataBinder::class, fn () => new FormsDataBinder());
5757

5858
app('router')->aliasMiddleware('forms', OverrideFormsDefaults::class);
59+
60+
// Register custom artisan commands
61+
if ($this->app->runningInConsole()) {
62+
$this->commands([
63+
\Javaabu\Forms\Commands\PublishViewCommand::class,
64+
]);
65+
}
5966
}
6067
}

0 commit comments

Comments
 (0)