Skip to content

Commit aed169b

Browse files
Fix
1 parent 9c40b52 commit aed169b

13 files changed

+815
-460
lines changed

app/Console/Commands/PublishScheduledContent.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Console\Commands;
44

5+
use Exception;
56
use App\Models\Content;
67
use App\Jobs\PublishScheduledContentJob;
78
use Illuminate\Console\Command;
@@ -34,7 +35,7 @@ public function handle()
3435
$publishedCount++;
3536
$this->info("Published: {$content->title}");
3637
Log::info("Auto-published scheduled content: {$content->title} (ID: {$content->id})");
37-
} catch (\Exception $e) {
38+
} catch (Exception $e) {
3839
$errorCount++;
3940
$this->error("Failed to publish: {$content->title} - {$e->getMessage()}");
4041
Log::error("Failed to auto-publish content {$content->id}: " . $e->getMessage());

app/Jobs/PublishScheduledContentJob.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Jobs;
44

5+
use Exception;
56
use App\Models\Content;
67
use Illuminate\Bus\Queueable;
78
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -41,7 +42,7 @@ public function handle()
4142
Log::info("Successfully published scheduled content: {$content->title} (ID: {$content->id})");
4243
}
4344

44-
} catch (\Exception $e) {
45+
} catch (Exception $e) {
4546
Log::error("Failed to publish scheduled content {$this->contentId}: " . $e->getMessage());
4647
throw $e;
4748
}

app/Models/Content.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace App\Models;
44

5+
use Str;
6+
use DB;
7+
use Hash;
58
use Exception;
69
use App\Services\FileService;
710
use App\Traits\IsTenantModel;
@@ -512,7 +515,7 @@ public function calculateReadingTime($wordsPerMinute = 200)
512515

513516
public function generateUniqueSlug($title)
514517
{
515-
$slug = \Str::slug($title);
518+
$slug = Str::slug($title);
516519
$originalSlug = $slug;
517520
$counter = 1;
518521

@@ -661,7 +664,7 @@ public function scopeSearch($query, $searchTerm)
661664
public function scopePopular($query, $days = 30)
662665
{
663666
return $query->withCount(['analytics as total_views' => function ($q) use ($days) {
664-
$q->where('date', '>=', now()->subDays($days))->select(\DB::raw('sum(views)'));
667+
$q->where('date', '>=', now()->subDays($days))->select(DB::raw('sum(views)'));
665668
}])->orderBy('total_views', 'desc');
666669
}
667670

@@ -727,13 +730,13 @@ public function isPasswordProtected()
727730
public function checkPassword($password)
728731
{
729732
return $this->isPasswordProtected() &&
730-
\Hash::check($password, $this->content_password);
733+
Hash::check($password, $this->content_password);
731734
}
732735

733736
public function setPassword($password)
734737
{
735738
$this->password_protected = true;
736-
$this->content_password = \Hash::make($password);
739+
$this->content_password = Hash::make($password);
737740
$this->save();
738741

739742
return $this;

app/Models/MediaLibrary.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Models;
44

5+
use Exception;
6+
use Log;
57
use Illuminate\Database\Eloquent\Factories\HasFactory;
68
use Illuminate\Database\Eloquent\Model;
79
use Illuminate\Support\Facades\Storage;
@@ -144,9 +146,9 @@ protected static function generateThumbnails($imagePath, $originalPath)
144146
'height' => $image->height(),
145147
];
146148

147-
} catch (\Exception $e) {
149+
} catch (Exception $e) {
148150
// Log error but continue
149-
\Log::warning("Failed to generate {$sizeName} thumbnail: " . $e->getMessage());
151+
Log::warning("Failed to generate {$sizeName} thumbnail: " . $e->getMessage());
150152
}
151153
}
152154

@@ -169,7 +171,7 @@ protected static function extractMetadata(UploadedFile $file, $options = [])
169171
if ($exifData) {
170172
$metadata['exif'] = $exifData;
171173
}
172-
} catch (\Exception $e) {
174+
} catch (Exception $e) {
173175
// EXIF data not available or corrupted
174176
}
175177
}

app/Providers/CMSServiceProvider.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace App\Providers;
44

5+
use Exception;
6+
use Log;
57
use Illuminate\Support\ServiceProvider;
68
use App\Services\PluginManager;
79
use App\Services\ThemeManager;
@@ -40,9 +42,9 @@ protected function loadActivePlugins()
4042
try {
4143
$pluginManager = $this->app->make(PluginManager::class);
4244
$pluginManager->loadActivePlugins();
43-
} catch (\Exception $e) {
45+
} catch (Exception $e) {
4446
// Log error but don't break the application
45-
\Log::warning('Failed to load plugins: ' . $e->getMessage());
47+
Log::warning('Failed to load plugins: ' . $e->getMessage());
4648
}
4749
}
4850

@@ -51,9 +53,9 @@ protected function loadActiveTheme()
5153
try {
5254
$themeManager = $this->app->make(ThemeManager::class);
5355
$themeManager->loadActiveTheme();
54-
} catch (\Exception $e) {
56+
} catch (Exception $e) {
5557
// Log error but don't break the application
56-
\Log::warning('Failed to load theme: ' . $e->getMessage());
58+
Log::warning('Failed to load theme: ' . $e->getMessage());
5759
}
5860
}
5961

app/Services/ContentAutomationService.php

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

33
namespace App\Services;
44

5+
use Exception;
56
use App\Models\Content;
67
use App\Jobs\PublishScheduledContentJob;
78
use Illuminate\Support\Facades\Queue;
@@ -81,7 +82,7 @@ public function processOverdueContent()
8182
$content->publish();
8283
$processedCount++;
8384
Log::info("Published overdue content: {$content->title}");
84-
} catch (\Exception $e) {
85+
} catch (Exception $e) {
8586
Log::error("Failed to publish overdue content {$content->id}: " . $e->getMessage());
8687
}
8788
}
@@ -99,7 +100,7 @@ public function bulkScheduleContent(array $contentIds, Carbon $publishDate)
99100
$content = Content::findOrFail($contentId);
100101
$this->scheduleContentPublication($content, $publishDate);
101102
$scheduled[] = $content;
102-
} catch (\Exception $e) {
103+
} catch (Exception $e) {
103104
$errors[] = [
104105
'content_id' => $contentId,
105106
'error' => $e->getMessage()

app/Services/ContentService.php

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

33
namespace App\Services;
44

5+
use Exception;
56
use App\Models\Content;
67
use App\Models\User;
78
use Illuminate\Support\Facades\Cache;
@@ -220,7 +221,7 @@ public function bulkImportContent(array $contentData)
220221

221222
$content->save();
222223
$imported[] = $content;
223-
} catch (\Exception $e) {
224+
} catch (Exception $e) {
224225
$errors[] = [
225226
'data' => $data,
226227
'error' => $e->getMessage()
@@ -229,7 +230,7 @@ public function bulkImportContent(array $contentData)
229230
}
230231

231232
DB::commit();
232-
} catch (\Exception $e) {
233+
} catch (Exception $e) {
233234
DB::rollback();
234235
throw $e;
235236
}

app/Services/PluginManager.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace App\Services;
44

5+
use Exception;
6+
use RecursiveIteratorIterator;
7+
use RecursiveDirectoryIterator;
58
use App\Models\Plugin;
69
use Illuminate\Support\Facades\File;
710
use Illuminate\Support\Facades\Artisan;
@@ -52,12 +55,12 @@ public function installPlugin($pluginData)
5255
$existingPlugin = Plugin::where('slug', $pluginData['slug'])->first();
5356

5457
if ($existingPlugin) {
55-
throw new \Exception("Plugin '{$pluginData['slug']}' already exists.");
58+
throw new Exception("Plugin '{$pluginData['slug']}' already exists.");
5659
}
5760

5861
// Validate compatibility
5962
if (!$this->checkCompatibility($pluginData)) {
60-
throw new \Exception("Plugin '{$pluginData['slug']}' is not compatible with current system.");
63+
throw new Exception("Plugin '{$pluginData['slug']}' is not compatible with current system.");
6164
}
6265

6366
// Create plugin record
@@ -89,7 +92,7 @@ public function installPlugin($pluginData)
8992

9093
return $plugin;
9194

92-
} catch (\Exception $e) {
95+
} catch (Exception $e) {
9396
Log::error("Failed to install plugin: " . $e->getMessage());
9497
throw $e;
9598
}
@@ -107,26 +110,26 @@ public function uploadAndInstallPlugin($zipFile)
107110
$zip->extractTo($tempDir);
108111
$zip->close();
109112
} else {
110-
throw new \Exception('Failed to extract plugin ZIP file.');
113+
throw new Exception('Failed to extract plugin ZIP file.');
111114
}
112115

113116
// Find plugin manifest
114117
$manifestPath = $this->findPluginManifest($tempDir);
115118
if (!$manifestPath) {
116-
throw new \Exception('Plugin manifest (plugin.json) not found.');
119+
throw new Exception('Plugin manifest (plugin.json) not found.');
117120
}
118121

119122
$manifest = json_decode(File::get($manifestPath), true);
120123
if (!$manifest || !$this->validateManifest($manifest)) {
121-
throw new \Exception('Invalid plugin manifest.');
124+
throw new Exception('Invalid plugin manifest.');
122125
}
123126

124127
// Move plugin to plugins directory
125128
$pluginSlug = $manifest['slug'];
126129
$pluginPath = $this->pluginsPath . '/' . $pluginSlug;
127130

128131
if (File::exists($pluginPath)) {
129-
throw new \Exception("Plugin directory '{$pluginSlug}' already exists.");
132+
throw new Exception("Plugin directory '{$pluginSlug}' already exists.");
130133
}
131134

132135
File::moveDirectory(dirname($manifestPath), $pluginPath);
@@ -144,7 +147,7 @@ public function uploadAndInstallPlugin($zipFile)
144147

145148
return $plugin;
146149

147-
} catch (\Exception $e) {
150+
} catch (Exception $e) {
148151
// Cleanup on failure
149152
if (isset($tempDir) && File::exists($tempDir)) {
150153
File::deleteDirectory($tempDir);
@@ -180,7 +183,7 @@ public function uninstallPlugin($pluginSlug)
180183

181184
return true;
182185

183-
} catch (\Exception $e) {
186+
} catch (Exception $e) {
184187
Log::error("Failed to uninstall plugin: " . $e->getMessage());
185188
throw $e;
186189
}
@@ -193,17 +196,17 @@ public function activatePlugin($pluginSlug)
193196

194197
// Check dependencies
195198
if (!$plugin->validateDependencies()) {
196-
throw new \Exception("Plugin dependencies not met.");
199+
throw new Exception("Plugin dependencies not met.");
197200
}
198201

199202
// Check compatibility
200203
if (!$plugin->checkCompatibility()) {
201-
throw new \Exception("Plugin not compatible with current system.");
204+
throw new Exception("Plugin not compatible with current system.");
202205
}
203206

204207
// Load plugin
205208
if (!$plugin->loadPlugin()) {
206-
throw new \Exception("Failed to load plugin main file.");
209+
throw new Exception("Failed to load plugin main file.");
207210
}
208211

209212
// Activate plugin
@@ -213,7 +216,7 @@ public function activatePlugin($pluginSlug)
213216

214217
return $plugin;
215218

216-
} catch (\Exception $e) {
219+
} catch (Exception $e) {
217220
Log::error("Failed to activate plugin: " . $e->getMessage());
218221
throw $e;
219222
}
@@ -229,7 +232,7 @@ public function deactivatePlugin($pluginSlug)
229232

230233
return $plugin;
231234

232-
} catch (\Exception $e) {
235+
} catch (Exception $e) {
233236
Log::error("Failed to deactivate plugin: " . $e->getMessage());
234237
throw $e;
235238
}
@@ -242,7 +245,7 @@ public function loadActivePlugins()
242245
foreach ($activePlugins as $plugin) {
243246
try {
244247
$plugin->loadPlugin();
245-
} catch (\Exception $e) {
248+
} catch (Exception $e) {
246249
Log::error("Failed to load plugin '{$plugin->slug}': " . $e->getMessage());
247250
}
248251
}
@@ -283,8 +286,8 @@ protected function checkCompatibility($pluginData)
283286

284287
protected function findPluginManifest($directory)
285288
{
286-
$iterator = new \RecursiveIteratorIterator(
287-
new \RecursiveDirectoryIterator($directory)
289+
$iterator = new RecursiveIteratorIterator(
290+
new RecursiveDirectoryIterator($directory)
288291
);
289292

290293
foreach ($iterator as $file) {
@@ -314,7 +317,7 @@ protected function runPluginMigrations($plugin, $action = 'install')
314317
'--force' => true
315318
]);
316319
}
317-
} catch (\Exception $e) {
320+
} catch (Exception $e) {
318321
Log::warning("Plugin migration failed for '{$plugin->slug}': " . $e->getMessage());
319322
}
320323
}

app/Services/ShortcodeService.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace App\Services;
44

5+
use Exception;
6+
use Log;
7+
use App\Models\Content;
8+
use App\Models\Plugin;
59
use Illuminate\Support\Facades\Cache;
610
use Illuminate\Support\Str;
711

@@ -62,8 +66,8 @@ protected function executeShortcode($tag, $attributes, $content)
6266
}
6367

6468
return '';
65-
} catch (\Exception $e) {
66-
\Log::error("Shortcode error for [{$tag}]: " . $e->getMessage());
69+
} catch (Exception $e) {
70+
Log::error("Shortcode error for [{$tag}]: " . $e->getMessage());
6771
return "<!-- Shortcode error: {$tag} -->";
6872
}
6973
}
@@ -250,7 +254,7 @@ protected function loadDefaultShortcodes()
250254
$type = $attributes['type'] ?? null;
251255
$category = $attributes['category'] ?? null;
252256

253-
$query = \App\Models\Content::published()->orderBy('published_at', 'desc');
257+
$query = Content::published()->orderBy('published_at', 'desc');
254258

255259
if ($type) {
256260
$query->where('type', $type);
@@ -280,7 +284,7 @@ protected function loadDefaultShortcodes()
280284
protected function loadPluginShortcodes()
281285
{
282286
// Load shortcodes from active plugins
283-
$pluginShortcodes = \App\Models\Plugin::getPluginShortcodes();
287+
$pluginShortcodes = Plugin::getPluginShortcodes();
284288

285289
foreach ($pluginShortcodes as $tag => $shortcodeData) {
286290
$this->register($tag, $shortcodeData['class']);

0 commit comments

Comments
 (0)