Skip to content

Commit 4e86b47

Browse files
Added operation helper
1 parent f065b6d commit 4e86b47

11 files changed

+69
-5
lines changed
25.1 KB
Loading
20.6 KB
Loading
40.4 KB
Loading
36.3 KB
Loading
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
use function DragonCode\LaravelDeployOperations\operation;
8+
9+
return new class extends Migration {
10+
public function withOperation(): string
11+
{
12+
return operation('');
13+
}
14+
};

docs/topics/operation-helper.topic

+12
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,16 @@
5858

5959
<code-block lang="bash" src="operations_helper.sh" include-lines="2" />
6060
</chapter>
61+
62+
<chapter title="Laravel Idea support" id="laravel_idea_support">
63+
<p>
64+
If you are using
65+
<a href="https://www.jetbrains.com/phpstorm/">JetBrains PhpStorm</a>
66+
with the
67+
<a href="https://laravel-idea.com">Laravel Idea</a> plugin installed,
68+
you can use the <code>operation</code> function to autocomplete.
69+
</p>
70+
71+
<img src="operation_helper_class.png" alt="operation helper" />
72+
</chapter>
6173
</topic>

docs/topics/running-operations.topic

+18
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,23 @@
262262
When the <code>%artisan% migrate:rollback</code> console command is called,
263263
the operation will call the <code>down</code> method if it exists in the operation file.
264264
</p>
265+
266+
<chapter title="Laravel Idea support" id="laravel_idea_support">
267+
<p>
268+
If you are using
269+
<a href="https://www.jetbrains.com/phpstorm/">JetBrains PhpStorm</a>
270+
with the
271+
<a href="https://laravel-idea.com">Laravel Idea</a> plugin installed,
272+
then autocomplete will be available to you:
273+
</p>
274+
<p>
275+
To avoid entering file names manually, you can use the <code>deploy_operation</code> helper function.
276+
All it does is to suggest IDE paths to operation files with recursive search.
277+
</p>
278+
279+
<code-block lang="php" src="with_operation_helper.php" include-lines="7-" />
280+
281+
<img src="operations_helper_function.png" alt="operation helper"/>
282+
</chapter>
265283
</chapter>
266284
</topic>

ide.json

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
"methodNames": [
3131
"run"
3232
],
33+
"functionFqn": [
34+
"DragonCode\\LaravelDeployOperations\\operation"
35+
],
3336
"place": "parameter",
3437
"parameters": [
3538
1

src/helpers.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DragonCode\LaravelDeployOperations;
6+
7+
if (! function_exists('\DragonCode\LaravelDeployOperations\operation')) {
8+
function operation(string $filename): string
9+
{
10+
return $filename;
11+
}
12+
}

tests/fixtures/migrations_with_operations/2025_03_31_213847_call_invokable.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44

55
use Illuminate\Database\Migrations\Migration;
66

7-
return new class extends Migration {
8-
public function up(): void {}
7+
use function DragonCode\LaravelDeployOperations\operation;
98

10-
public function down(): void {}
9+
return new class extends Migration {
10+
public function up(): void
11+
{
12+
//
13+
}
1114

1215
public function withOperation(): string
1316
{
14-
return '2025_03_31_234251_invoke';
17+
return operation('2025_03_31_234251_invoke');
1518
}
1619
};

tests/fixtures/migrations_with_operations/2025_03_31_213921_call_up_down.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
use Illuminate\Database\Migrations\Migration;
66

7+
use function DragonCode\LaravelDeployOperations\operation;
8+
79
return new class extends Migration {
810
public function up(): void {}
911

1012
public function down(): void {}
1113

1214
public function withOperation(): string
1315
{
14-
return '2025_03_31_234312_up_down';
16+
return operation('2025_03_31_234312_up_down');
1517
}
1618
};

0 commit comments

Comments
 (0)