Skip to content

Commit c4b6635

Browse files
committed
command auto-registration
1 parent a18453d commit c4b6635

File tree

3 files changed

+30
-38
lines changed

3 files changed

+30
-38
lines changed

readme-ru.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# LaravelFileCleaner
88

9-
LaravelFileCleaner - это пакет для Laravel 5.1-5.2, который позвлоляет удалять временные файлы и связанные с ними сущности модели (при необходимости).
9+
LaravelFileCleaner - это пакет для Laravel 5, который позвлоляет удалять временные файлы и связанные с ними сущности модели (при необходимости).
1010

1111
## Установка
1212

@@ -51,15 +51,7 @@ php artisan vendor:publish --provider="MasterRO\LaravelFileCleaner\FileCleanerSe
5151

5252
### Scheduling
5353

54-
В Command/Kernel.php добавьте `FileCleaner::class`:
55-
56-
```php
57-
protected $commands = [
58-
\MasterRO\LaravelFileCleaner\FileCleaner::class,
59-
];
60-
```
61-
62-
Затем добавьте вызов команды в фукцию `schedule`:
54+
Добавьте вызов команды в фукцию `schedule`:
6355
> [Документация по Task Scheduling](https://laravel.com/docs/5.2/scheduling), если есть вопросы.
6456
6557
```php

readme.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,8 @@ For this package you may set such configurations:
6666
## Usage
6767

6868
### Scheduling
69-
In your Command kernel file add `FileCleaner::class`:
7069

71-
```php
72-
protected $commands = [
73-
\MasterRO\LaravelFileCleaner\FileCleaner::class,
74-
];
75-
```
76-
77-
Then add new command call to schedule function:
70+
Add new command call to schedule function:
7871
> Have a look at [Laravel's task scheduling documentation](https://laravel.com/docs/5.2/scheduling), if you need any help.
7972
8073
```php

src/FileCleanerServiceProvider.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,32 @@
77
class FileCleanerServiceProvider extends ServiceProvider
88
{
99

10-
/**
11-
* Boot the service provider.
12-
*
13-
* @return void
14-
*/
15-
public function boot()
16-
{
17-
$this->publishes([
18-
__DIR__ . '/file-cleaner.php' => config_path('file-cleaner.php'),
19-
]);
20-
}
10+
/**
11+
* Boot the service provider.
12+
*
13+
* @return void
14+
*/
15+
public function boot()
16+
{
17+
$this->publishes([
18+
__DIR__ . '/file-cleaner.php' => config_path('file-cleaner.php'),
19+
]);
2120

22-
/**
23-
* Register the service provider.
24-
*
25-
* @return void
26-
*/
27-
public function register()
28-
{
29-
//
30-
}
21+
if ($this->app->runningInConsole()) {
22+
$this->commands([
23+
FileCleaner::class,
24+
]);
25+
}
26+
}
27+
28+
29+
/**
30+
* Register the service provider.
31+
*
32+
* @return void
33+
*/
34+
public function register()
35+
{
36+
//
37+
}
3138
}

0 commit comments

Comments
 (0)