Conditions | 6 |
Paths | 32 |
Total Lines | 100 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
44 | public function handle() |
||
45 | { |
||
46 | $this->comment('Publishing the blog assets...'); |
||
47 | // Backup |
||
48 | $this->callSilent( |
||
49 | 'vendor:publish', |
||
50 | [ |
||
51 | '--provider' => BackupServiceProvider::class, |
||
52 | ] |
||
53 | ); |
||
54 | // CSP |
||
55 | $this->callSilent( |
||
56 | 'vendor:publish', |
||
57 | [ |
||
58 | '--tag' => 'config', |
||
59 | '--provider' => CspServiceProvider::class, |
||
60 | ] |
||
61 | ); |
||
62 | // RSS Feed |
||
63 | $this->callSilent( |
||
64 | 'vendor:publish', |
||
65 | [ |
||
66 | '--tag' => 'config', |
||
67 | '--provider' => FeedServiceProvider::class, |
||
68 | ] |
||
69 | ); |
||
70 | // media library |
||
71 | $this->callSilent( |
||
72 | 'vendor:publish', |
||
73 | [ |
||
74 | '--tag' => 'config', |
||
75 | '--provider' => MediaLibraryServiceProvider::class, |
||
76 | ] |
||
77 | ); |
||
78 | // check if media table exists |
||
79 | if (! Schema::hasTable('media')) { |
||
80 | $this->callSilent( |
||
81 | 'vendor:publish', |
||
82 | [ |
||
83 | '--tag' => 'migrations', |
||
84 | '--provider' => MediaLibraryServiceProvider::class, |
||
85 | ] |
||
86 | ); |
||
87 | } |
||
88 | |||
89 | // Missing page redirector |
||
90 | $this->callSilent( |
||
91 | 'vendor:publish', |
||
92 | [ |
||
93 | '--provider' => MissingPageRedirectorServiceProvider::class, |
||
94 | ] |
||
95 | ); |
||
96 | // Response Cache |
||
97 | $this->callSilent( |
||
98 | 'vendor:publish', |
||
99 | [ |
||
100 | '--provider' => ResponseCacheServiceProvider::class, |
||
101 | ] |
||
102 | ); |
||
103 | // tags |
||
104 | $this->callSilent( |
||
105 | 'vendor:publish', |
||
106 | [ |
||
107 | '--tag' => 'config', |
||
108 | '--provider' => TagsServiceProvider::class, |
||
109 | ] |
||
110 | ); |
||
111 | if (! Schema::hasTable('tags')) { |
||
112 | $this->callSilent( |
||
113 | 'vendor:publish', |
||
114 | [ |
||
115 | '--tag' => 'migrations', |
||
116 | '--provider' => TagsServiceProvider::class, |
||
117 | ] |
||
118 | ); |
||
119 | } |
||
120 | // Blog migrations |
||
121 | $this->callSilent('vendor:publish', ['--tag' => 'blog.config']); |
||
122 | $this->callSilent('vendor:publish', ['--tag' => 'blog.migrations']); |
||
123 | $this->callSilent('vendor:publish', ['--tag' => 'blog.assets']); |
||
124 | $this->info('Blog scaffolding installed successfully.'); |
||
125 | // run the migrations and seeds |
||
126 | $this->comment('Running the database migrations...'); |
||
127 | $this->call('migrate'); |
||
128 | |||
129 | if (! file_exists(public_path('storage'))) { |
||
130 | $this->call('storage:link'); |
||
131 | } |
||
132 | // Link the theme? |
||
133 | if ($this->confirm('Link the theme\'s public assets?')) { |
||
134 | $this->call('blog:theme-publish'); |
||
135 | } |
||
136 | // Seed the database |
||
137 | if ($this->confirm('Seed the database (recommended for new installations)')) { |
||
138 | $this->comment('Seeding the database with default data...'); |
||
139 | $this->call('db:seed', ['--class' => UsersTableSeeder::class]); |
||
140 | } |
||
141 | |||
142 | $admin_url = url(config('blog.prefix')); |
||
143 | $this->info('Installation complete. You can login to the admin '.$admin_url); |
||
|
|||
144 | } |
||
146 |