Skip to content

Commit 9ce5919

Browse files
committed
WIP: Commands for basic scaffolding
1 parent 5e0e31a commit 9ce5919

File tree

7 files changed

+42
-282
lines changed

7 files changed

+42
-282
lines changed

database/factories/PostFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
'content' => $faker->paragraph,
1717
'status' => 'published',
1818
'published_at' => now(),
19+
'allow_comments' => true,
20+
'allow_guest_comments' => true,
1921
];
2022
});

database/migrations/2019_12_28_101010_create_posts_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ public function up()
2626
$table->text('content')->nullable();
2727

2828
$table->boolean('allow_comments')->default(
29-
config('blogs.posts.allow_comments')
29+
config('blog.posts.allow_comments')
3030
)->nullable();
3131

3232
$table->boolean('allow_guest_comments')->default(
33-
config('blogs.posts.allow_guest_comments')
33+
config('blog.posts.allow_guest_comments')
3434
)->nullable();
3535

3636
$table->string('status')->nullable();

src/BlogServiceProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private function routeConfiguration()
9494
private function handleMigrations()
9595
{
9696
if ($this->app->runningInConsole()) {
97-
$this->loadMigrationsFrom(__DIR__.'/../database/migrations/');
97+
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
9898
}
9999
}
100100

@@ -106,16 +106,19 @@ private function handleMigrations()
106106
private function handlePublishing()
107107
{
108108
if ($this->app->runningInConsole()) {
109+
110+
// TODO: Are these really needed?
109111
$this->publishes([
110112
__DIR__.'/../database/factories/' => database_path('factories'),
111113
], 'blog-factories');
112114

115+
// TODO: Are these really needed?
113116
$this->publishes([
114117
__DIR__.'/../database/seeds/' => database_path('seeds'),
115118
], 'blog-seeders');
116119

117120
$this->publishes([
118-
__DIR__.'/../config/blogs.php' => config_path('blogs.php'),
121+
__DIR__.'/../config/blog.php' => config_path('blog.php'),
119122
], 'blog-config');
120123
}
121124
}
@@ -138,7 +141,6 @@ private function handleCommands()
138141
{
139142
$this->commands([
140143
\Chriscreates\Blog\Console\Commands\InstallCommand::class,
141-
\Chriscreates\Blog\Console\Commands\PublishCommand::class,
142144
\Chriscreates\Blog\Console\Commands\SetupCommand::class,
143145
]);
144146
}

src/Comment.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
namespace Chriscreates\Blog;
44

55
use Chriscreates\Blog\Builders\CommentBuilder;
6-
use Chriscreates\Blog\Traits\Comment\CommentApproval;
76
use Chriscreates\Blog\Traits\IsAuthorable;
87
use Illuminate\Database\Eloquent\Model;
98

109
class Comment extends Model
1110
{
12-
use CommentApproval,
13-
IsAuthorable;
11+
use IsAuthorable;
1412

1513
protected $table = 'comments';
1614

src/Console/Commands/InstallCommand.php

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

55
use Illuminate\Console\Command;
66
use Illuminate\Console\DetectsApplicationNamespace;
7-
use Illuminate\Support\Str;
87

98
class InstallCommand extends Command
109
{
@@ -34,45 +33,10 @@ public function handle()
3433
$this->callSilent('vendor:publish', ['--tag' => 'blog-factories']);
3534
$this->callSilent('vendor:publish', ['--tag' => 'blog-seeders']);
3635
$this->callSilent('vendor:publish', ['--tag' => 'blog-config']);
37-
// $this->callSilent('migrate');
38-
//
39-
// $this->registerCanvasServiceProvider();
36+
$this->callSilent('migrate');
4037

41-
$this->info('Installation complete.');
42-
}
38+
// TODO: Do we need to publish a provider?
4339
44-
/**
45-
* Register the Canvas service provider in the application configuration file.
46-
*
47-
* @return void
48-
*/
49-
private function registerCanvasServiceProvider()
50-
{
51-
$namespace = Str::replaceLast('\\', '', $this->getAppNamespace());
52-
$appConfig = file_get_contents(config_path('app.php'));
53-
54-
if (Str::contains($appConfig, $namespace.'\\Providers\\CanvasServiceProvider::class')) {
55-
return;
56-
}
57-
58-
$lineEndingCount = [
59-
"\r\n" => substr_count($appConfig, "\r\n"),
60-
"\r" => substr_count($appConfig, "\r"),
61-
"\n" => substr_count($appConfig, "\n"),
62-
];
63-
64-
$eol = array_keys($lineEndingCount, max($lineEndingCount))[0];
65-
66-
file_put_contents(config_path('app.php'), str_replace(
67-
"{$namespace}\\Providers\EventServiceProvider::class,".$eol,
68-
"{$namespace}\\Providers\EventServiceProvider::class,".$eol." {$namespace}\Providers\CanvasServiceProvider::class,".$eol,
69-
$appConfig
70-
));
71-
72-
file_put_contents(app_path('Providers/CanvasServiceProvider.php'), str_replace(
73-
"namespace App\Providers;",
74-
"namespace {$namespace}\Providers;",
75-
file_get_contents(app_path('Providers/CanvasServiceProvider.php'))
76-
));
40+
$this->info('Installation complete.');
7741
}
7842
}

src/Console/Commands/PublishCommand.php

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

0 commit comments

Comments
 (0)