Skip to content

Commit 0d33f05

Browse files
Add PHP CS Fixer configuration file for code style enforcement and update README for clarity. Adjust composer dependencies to support PHP 8.3 and improve modal optional div link handling in the view. (#32)
* Add PHP CS Fixer configuration file for code style enforcement and update README for clarity. Adjust composer dependencies to support PHP 8.3 and improve modal optional div link handling in the view. * Fix styling * Update package versions in composer.json to support newer releases of dependencies. * Update GitHub Actions workflow to reduce test timeout, expand OS and PHP versions, and include additional Laravel versions for improved compatibility and testing coverage. Remove unnecessary GitHub token configuration steps. * Update GitHub Actions workflow permissions to read-only for pull requests and contents, enhancing security. Add .php-cs-fixer.cache to .gitignore to prevent unnecessary files from being tracked.
1 parent 8c29e48 commit 0d33f05

File tree

11 files changed

+65
-151
lines changed

11 files changed

+65
-151
lines changed

.github/workflows/fix-php-code-style-issues.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/run-tests.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
- main
99

1010
permissions:
11-
pull-requests: write
12-
contents: write
11+
pull-requests: read
12+
contents: read
1313

1414
jobs:
1515
test:
@@ -48,13 +48,6 @@ jobs:
4848
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
4949
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
5050
51-
- name: Configure GitHub Token
52-
env:
53-
GH_TOKEN: ${{ secrets.GHA_PERSONAL_ACCESS_TOKEN }}
54-
run: |
55-
git config --global url."https://${GH_TOKEN}@github.com/".insteadOf "https://github.com/"
56-
git config --global url."https://${GH_TOKEN}@github.com/".insteadOf "[email protected]:"
57-
5851
- name: Install dependencies
5952
run: |
6053
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ yarn-error.log
3131
php.ini
3232
error_log
3333
.DS_Store
34+
.php-cs-fixer.cache

.php-cs-fixer.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

.php-cs-fixer.dist.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
$finder = Symfony\Component\Finder\Finder::create()
4+
->notPath('bootstrap/*')
5+
->notPath('storage/*')
6+
->notPath('resources/view/mail/*')
7+
->in([
8+
__DIR__ . '/src',
9+
__DIR__ . '/tests',
10+
])
11+
->name('*.php')
12+
->notName('*.blade.php')
13+
->ignoreDotFiles(true)
14+
->ignoreVCS(true);
15+
16+
return (new PhpCsFixer\Config())
17+
->setRules([
18+
'@PSR2' => true,
19+
'array_syntax' => ['syntax' => 'short'],
20+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
21+
'no_unused_imports' => true,
22+
'not_operator_with_successor_space' => true,
23+
'trailing_comma_in_multiline' => true,
24+
'phpdoc_scalar' => true,
25+
'unary_operator_spaces' => true,
26+
'binary_operator_spaces' => true,
27+
'blank_line_before_statement' => [
28+
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
29+
],
30+
'phpdoc_single_line_var_spacing' => true,
31+
'phpdoc_var_without_name' => true,
32+
'class_attributes_separation' => [
33+
'elements' => [
34+
'method' => 'one',
35+
],
36+
],
37+
'method_argument_space' => [
38+
'on_multiline' => 'ensure_fully_multiline',
39+
'keep_multiple_spaces_after_comma' => true,
40+
],
41+
'single_trait_insert_per_statement' => true,
42+
])
43+
->setFinder($finder);

README.md

Lines changed: 2 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -22,103 +22,6 @@ You can manually publish the config file with:
2222
php artisan vendor:publish --tag="forms-config"
2323
```
2424

25-
This is the contents of the published config file:
26-
27-
```php
28-
return [
29-
'forms' => [
30-
'free_estimate' => [
31-
'production_url' => 'https://fuelforms.com/api/f/',
32-
'development_url' => 'https://dev.fuelforms.com/api/f/',
33-
],
34-
35-
'contact_us' => [
36-
'production_url' => 'https://fuelforms.com/api/f/',
37-
'development_url' => 'https://dev.fuelforms.com/api/f/',
38-
],
39-
40-
'careers' => [
41-
'production_url' => 'https://fuelforms.com/api/f/',
42-
'development_url' => 'https://dev.fuelforms.com/api/f/',
43-
],
44-
],
45-
46-
'modal' => [
47-
'title' => 'Your Project Info',
48-
'form_key' => 'free_estimate',
49-
50-
'steps' => [
51-
1 => [
52-
'heading' => 'Where do you need painting?',
53-
'locations' => [
54-
'inside',
55-
'outside',
56-
'cabinets',
57-
],
58-
],
59-
],
60-
61-
'tos' => [
62-
'enabled' => true,
63-
'content' => 'By clicking "Submit" above, I expressly consent to...',
64-
],
65-
66-
'optional_div' => [
67-
'enabled' => true,
68-
'title' => 'Looking to work with us?',
69-
'link_text' => 'Apply Here',
70-
'link_route' => 'welcome',
71-
],
72-
],
73-
74-
'validation' => [
75-
'default' => [
76-
'firstName' => 'required|min:2|max:24',
77-
'lastName' => 'required|min:2|max:24',
78-
'email' => 'required|email',
79-
'phone' => 'required|min:7|max:19',
80-
'message' => 'nullable|max:255',
81-
],
82-
83-
'free_estimate' => [
84-
'firstName' => 'required|min:2|max:24',
85-
'lastName' => 'required|min:2|max:24',
86-
'email' => 'required|email',
87-
'phone' => 'required|min:7|max:19',
88-
'message' => 'nullable|max:255',
89-
],
90-
91-
'contact_us' => [
92-
'firstName' => 'required|min:2|max:24',
93-
'lastName' => 'required|min:2|max:24',
94-
'email' => 'required|email',
95-
'phone' => 'required|min:7|max:19',
96-
'message' => 'nullable|max:255',
97-
],
98-
99-
'steps' => [
100-
1 => [
101-
'location' => 'required|in:inside,outside,cabinets',
102-
],
103-
2 => [
104-
'firstName' => 'required|min:2|max:24',
105-
'lastName' => 'required|min:2|max:24',
106-
'email' => 'required|email',
107-
'phone' => 'required|min:7|max:19',
108-
'zipCode' => 'required|min:4|max:9',
109-
'message' => 'nullable|max:255',
110-
'location' => 'required|in:inside,outside,cabinets',
111-
],
112-
],
113-
],
114-
115-
'spam_redirects' => [
116-
'yelp' => 'https://yelp.com',
117-
'bbb' => 'https://bbb.org',
118-
],
119-
];
120-
```
121-
12225
You can publish the view files with:
12326

12427
```bash
@@ -299,7 +202,8 @@ Please review [our security policy](../../security/policy) on how to report secu
299202

300203
## Credits
301204

302-
- [Thejmitchener](https://github.com/thejmitchener)
205+
- [Joshua Mitchener](https://github.com/thejmitchener)
206+
- [Daniel Clark](https://github.com/sweatybreeze)
303207
- [Fuelviews](https://github.com/fuelviews)
304208
- [All Contributors](../../contributors)
305209

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@
44
"keywords": [
55
"fuelviews",
66
"laravel",
7-
"laravel-forms",
87
"forms"
98
],
109
"homepage": "https://github.com/fuelviews/laravel-forms",
1110
"license": "MIT",
1211
"authors": [
1312
{
1413
"name": "Joshua Mitchener",
15-
"email": "[email protected]",
1614
"homepage": "https://fuelviews.com",
1715
"role": "Developer"
1816
}
1917
],
2018
"require": {
21-
"php": "^8.2",
22-
"spatie/laravel-package-tools": "^1.16"
19+
"php": "^8.3||^8.2",
20+
"spatie/laravel-package-tools": "^1.16",
21+
"illuminate/contracts": "^10.0||^11.0||^12.0"
2322
},
2423
"require-dev": {
2524
"fuelviews/laravel-sabhero-wrapper": ">=0.0",
2625
"laravel/pint": "^1.14",
2726
"livewire/livewire": ">=3.5",
2827
"nunomaduro/collision": "^8.1.1||^7.10.0",
29-
"orchestra/testbench": "^9.0.0||^8.22.0",
30-
"pestphp/pest": "^2.34",
31-
"pestphp/pest-plugin-arch": "^2.7",
32-
"pestphp/pest-plugin-laravel": "^2.3"
28+
"orchestra/testbench": "^10.2||^9.0.0||^8.22.0",
29+
"pestphp/pest": "^3.0||^2.34",
30+
"pestphp/pest-plugin-arch": "^3.0||^2.7",
31+
"pestphp/pest-plugin-laravel": "^3.2||^2.3"
3332
},
3433
"autoload": {
3534
"psr-4": {
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
@if (Forms::isModalOptionalDivEnabled())
22
<div class="bg-gray-100 text-xs md:text-sm md:text-md p-2 rounded-tl-lg rounded-br-lg text-center -mb-4 -mr-4">
33
<span class="block text-gray-900">{{ Forms::getModalOptionalDivTitle() }}</span>
4-
<a href="{{ route(Forms::getModalOptionalDivLinkRoute()) }}" class="text-blue-500 text-blue-700 hover:underline text-sm">{{ Forms::getModalOptionalDivLinkText() }}</a>
4+
@php
5+
$routeName = Forms::getModalOptionalDivLinkRoute();
6+
$routeExists = Route::has($routeName);
7+
@endphp
8+
<a href="{{ $routeExists ? route($routeName) : '#' }}" class="text-blue-500 text-blue-700 hover:underline text-sm">{{ Forms::getModalOptionalDivLinkText() }}</a>
59
</div>
610
@endif

src/Commands/FormsInstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Console\Command;
66
use Symfony\Component\Process\Exception\ProcessFailedException;
77
use Symfony\Component\Process\Process;
8-
use Spatie\LaravelPackageTools\Commands\InstallCommand;
98

109
class FormsInstallCommand extends Command
1110
{
@@ -33,6 +32,7 @@ public function handle(): int
3332
$this->info('✅ Packages installed successfully.');
3433
} catch (ProcessFailedException $e) {
3534
$this->error('❌ Failed to install packages: ' . $e->getMessage());
35+
3636
return self::FAILURE;
3737
}
3838

src/FormsServiceProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
use Fuelviews\Forms\Middleware\HandleUtm;
1111
use Fuelviews\Forms\Services\FormsSubmitService;
1212
use Fuelviews\Forms\Services\FormsValidationRuleService;
13-
use Illuminate\Support\Facades\Route;
14-
use Illuminate\Foundation\Application;
1513
use Illuminate\Contracts\Http\Kernel;
14+
use Illuminate\Foundation\Application;
1615
use Illuminate\Foundation\Configuration\Middleware;
16+
use Illuminate\Support\Facades\Route;
1717
use Livewire\Livewire;
1818
use Spatie\LaravelPackageTools\Package;
1919
use Spatie\LaravelPackageTools\PackageServiceProvider;
@@ -83,7 +83,6 @@ public function registeringPackage(): void
8383
});
8484
}
8585

86-
8786
private function providerIsLoaded($app, $providerClass): bool
8887
{
8988
return collect($app->getLoadedProviders())->has($providerClass);

src/Http/Controllers/FormsSubmitController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public function handleSubmit(Request $request)
4444
if (is_array($result) && $result['status'] === 'failure') {
4545
session()->flash('status', 'failure');
4646
session()->flash('message', $result['message'] ?? 'There was an issue submitting the form.');
47+
4748
return back()->withInput();
4849
}
4950

@@ -54,6 +55,7 @@ public function handleSubmit(Request $request)
5455
'status' => session('status'),
5556
'message' => session('message'),
5657
]);
58+
5759
return redirect()->route('forms.thank-you');
5860
}
5961
}

0 commit comments

Comments
 (0)