diff --git a/composer.json b/composer.json index 445f75f9..10255e52 100644 --- a/composer.json +++ b/composer.json @@ -64,7 +64,10 @@ "autoload": { "psr-4": { "DragonCode\\LaravelDeployOperations\\": "src/" - } + }, + "files": [ + "src/helpers.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/docs/images/operation_helper_class.png b/docs/images/operation_helper_class.png new file mode 100644 index 00000000..e2ab8e35 Binary files /dev/null and b/docs/images/operation_helper_class.png differ diff --git a/docs/images/operation_helper_class_dark.png b/docs/images/operation_helper_class_dark.png new file mode 100644 index 00000000..d7c269e3 Binary files /dev/null and b/docs/images/operation_helper_class_dark.png differ diff --git a/docs/images/operations_helper_function.png b/docs/images/operations_helper_function.png new file mode 100644 index 00000000..42d7afed Binary files /dev/null and b/docs/images/operations_helper_function.png differ diff --git a/docs/images/operations_helper_function_dark.png b/docs/images/operations_helper_function_dark.png new file mode 100644 index 00000000..ee29c790 Binary files /dev/null and b/docs/images/operations_helper_function_dark.png differ diff --git a/docs/snippets/with_operation_helper.php b/docs/snippets/with_operation_helper.php new file mode 100644 index 00000000..465e326b --- /dev/null +++ b/docs/snippets/with_operation_helper.php @@ -0,0 +1,14 @@ + + + +

+ If you are using + JetBrains PhpStorm + with the + Laravel Idea plugin installed, + you can use the operation function to autocomplete. +

+ + operation helper +
diff --git a/docs/topics/running-operations.topic b/docs/topics/running-operations.topic index d3904972..4badf1c5 100644 --- a/docs/topics/running-operations.topic +++ b/docs/topics/running-operations.topic @@ -262,5 +262,23 @@ When the %artisan% migrate:rollback console command is called, the operation will call the down method if it exists in the operation file.

+ + +

+ If you are using + JetBrains PhpStorm + with the + Laravel Idea plugin installed, + then autocomplete will be available to you: +

+

+ To avoid entering file names manually, you can use the deploy_operation helper function. + All it does is to suggest IDE paths to operation files with recursive search. +

+ + + + operation helper +
diff --git a/ide.json b/ide.json index 742e09a1..076195ae 100644 --- a/ide.json +++ b/ide.json @@ -30,6 +30,9 @@ "methodNames": [ "run" ], + "functionFqn": [ + "DragonCode\\LaravelDeployOperations\\operation" + ], "place": "parameter", "parameters": [ 1 diff --git a/src/helpers.php b/src/helpers.php new file mode 100644 index 00000000..620e27cc --- /dev/null +++ b/src/helpers.php @@ -0,0 +1,12 @@ +assertSuccessful(); $this->assertDatabaseCount($table, 1); - $this->assertDatabaseCount($this->table, 0); + $this->assertDatabaseCount($this->table, 1); $this->assertDatabaseOperationDoesntLike($this->table, 'custom'); - $this->assertDatabaseOperationDoesntLike($this->table, 'invoke'); + $this->assertDatabaseOperationHas($this->table, 'invoke'); $this->assertDatabaseOperationDoesntLike($this->table, 'up_down'); $this->assertDatabaseOperationDoesntLike($table, 'custom', column: 'value'); $this->assertDatabaseOperationHas($table, 'invoke', column: 'value'); diff --git a/tests/fixtures/migrations_with_operations/2025_03_31_213847_call_invokable.php b/tests/fixtures/migrations_with_operations/2025_03_31_213847_call_invokable.php index 138e8a7b..95f759a6 100644 --- a/tests/fixtures/migrations_with_operations/2025_03_31_213847_call_invokable.php +++ b/tests/fixtures/migrations_with_operations/2025_03_31_213847_call_invokable.php @@ -4,13 +4,13 @@ use Illuminate\Database\Migrations\Migration; +use function DragonCode\LaravelDeployOperations\operation; + return new class extends Migration { public function up(): void {} - public function down(): void {} - public function withOperation(): string { - return '2025_03_31_234251_invoke'; + return operation('2025_03_31_234251_invoke'); } }; diff --git a/tests/fixtures/migrations_with_operations/2025_03_31_213921_call_up_down.php b/tests/fixtures/migrations_with_operations/2025_03_31_213921_call_up_down.php index 7f70fd87..009b4e7d 100644 --- a/tests/fixtures/migrations_with_operations/2025_03_31_213921_call_up_down.php +++ b/tests/fixtures/migrations_with_operations/2025_03_31_213921_call_up_down.php @@ -4,6 +4,8 @@ use Illuminate\Database\Migrations\Migration; +use function DragonCode\LaravelDeployOperations\operation; + return new class extends Migration { public function up(): void {} @@ -11,6 +13,6 @@ public function down(): void {} public function withOperation(): string { - return '2025_03_31_234312_up_down'; + return operation('2025_03_31_234312_up_down'); } };