Skip to content

Commit 0429a0c

Browse files
committed
added console command
1 parent 5e5869b commit 0429a0c

File tree

3 files changed

+58
-4
lines changed

3 files changed

+58
-4
lines changed

Console/Inspire.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Modules\MyBlog\Console;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Foundation\Inspiring;
7+
8+
class Inspire extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'my-blog:inspire';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'Get an inspiring quote';
23+
24+
/**
25+
* Execute the console command.
26+
*
27+
* @return mixed
28+
*/
29+
public function handle()
30+
{
31+
$quote = Inspiring::quote();
32+
33+
$this->info($quote);
34+
}
35+
}

Providers/Main.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Models\Auth\User;
66
use App\Models\Setting\Category;
7+
use Illuminate\Console\Scheduling\Schedule;
78
use Illuminate\Support\Facades\Blade;
89
use Illuminate\Support\Facades\Config;
910
use Illuminate\Support\ServiceProvider as Provider;
@@ -33,6 +34,7 @@ public function boot()
3334
$this->loadMigrations();
3435
$this->loadConfig();
3536
$this->loadDynamicRelationships();
37+
$this->loadCommands();
3638
}
3739

3840
/**
@@ -114,6 +116,22 @@ public function loadDynamicRelationships()
114116
});
115117
}
116118

119+
/**
120+
* Load commands.
121+
*
122+
* @return void
123+
*/
124+
public function loadCommands()
125+
{
126+
$this->commands(\Modules\MyBlog\Console\Inspire::class);
127+
128+
$this->app->booted(function () {
129+
$schedule_time = config('app.schedule_time', '09:00');
130+
131+
app(Schedule::class)->command('my-blog:inspire')->dailyAt($schedule_time);
132+
});
133+
}
134+
117135
/**
118136
* Load routes.
119137
*

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ This is an example module with beyond CRUD functions for admin and is shown in t
1515

1616
## Features
1717

18-
- [x] API ([provider](Providers/Main.php#L131), [route](Routes/api.php), [controller](Http/Controllers/Api), [transformer](Transformers))
18+
- [x] API ([provider](Providers/Main.php#L149), [route](Routes/api.php), [controller](Http/Controllers/Api), [transformer](Transformers))
1919
- [x] Bulk Actions ([class](BulkActions), [blade](Resources/views/posts/index.blade.php#L27), [vuejs](Resources/assets/js/my-blog.js))
20-
- [x] Category Type ([provider](Providers/Main.php#L85), [config](Config/type.php), [model](Models/Post.php#L23))
20+
- [x] Category Type ([provider](Providers/Main.php#L87), [config](Config/type.php), [model](Models/Post.php#L23))
2121
- [x] Client Portal
2222
- [x] ~~Contact Type~~
23+
- [x] Console Command ([provider](Providers/Main.php#L124), [command](Console/Inspire.php))
2324
- [x] CRUD
2425
- [x] Dashboard ([seed](Database/Seeds/Install.php#L20))
2526
- [x] ~~Document Type~~
26-
- [x] Dynamic Relationships ([define](Providers/Main.php#L35), [use](Widgets/PostsByCategory.php#L18))
27+
- [x] Dynamic Relationships ([define](Providers/Main.php#L104), [use](Widgets/PostsByCategory.php#L18))
2728
- [x] Email Templates ([seed](Database/Seeds/Install.php#L21), [content](Resources/lang/en-GB/email_templates.php))
2829
- [x] Exports ([controller](Http/Controllers/Posts.php#L244), [class](Exports))
2930
- [x] Imports ([controller](Http/Controllers/Posts.php#L117), [class](Imports))
@@ -34,7 +35,7 @@ This is an example module with beyond CRUD functions for admin and is shown in t
3435
- [x] Ownership (`created_by` [field](Models/Post.php#L14), [controller](Http/Controllers/Posts.php#L26), [blade](Resources/views/posts/index.blade.php#L54))
3536
- [x] Permissions ([listener](Listeners/FinishInstallation.php#L32))
3637
- [x] Reports ([define](module.json#L13), [report](Reports/PostSummary.php), [listener](Listeners/AddCategoriesToReport.php))
37-
- [x] Search String ([provider](Providers/Main.php#L85), [config](Config/search-string.php#L5), [blade](Resources/views/posts/index.blade.php#L24))
38+
- [x] Search String ([provider](Providers/Main.php#L87), [config](Config/search-string.php#L5), [blade](Resources/views/posts/index.blade.php#L24))
3839
- [x] Seeds ([listener](Listeners/FinishInstallation.php#L29), [seeder](Database/Seeds/Install.php))
3940
- [x] Settings ([define](module.json#L27), [use](Http/Controllers/Posts.php#L38))
4041
- [x] Tests ([feature](Tests/Feature))

0 commit comments

Comments
 (0)