Skip to content

Commit

Permalink
feat: add post_id index to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Sep 20, 2023
1 parent 045a3c4 commit f1a719a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 8 additions & 0 deletions src/database/migrations/2023_09_20_040645_add_indexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public function up(): void
$table->string('category')->nullable(false)->change();
$table->unique('category');
});

Schema::table('comments', function (Blueprint $table) {
$table->index(['post_id']);
});
}

/**
Expand All @@ -26,5 +30,9 @@ public function down(): void
$table->dropUnique(['category']);
$table->string('category')->nullable(true)->change();
});

Schema::table('comments', function (Blueprint $table) {
$table->dropIndex('comments_post_id_index');
});
}
};
6 changes: 1 addition & 5 deletions src/resources/views/post.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
<i class="fas fa-clock"></i>
{{ \App\Http\Controllers\PostController::generateReadingTime($post) }} minutes
<i class="fas fa-tag"></i>
@if (isset($post->category->category))
<a href="{{ '/posts/category/' . $post->category->category }}">{{ $post->category->category }}</a>
@else
{{ 'Uncategorized' }}
@endif
<a href="{{ '/posts/category/' . $post->category->category }}">{{ $post->category->category }}</a>
</p>
<div class="banner-image-container">
@if (isset($post->banner_image_url) &&
Expand Down
6 changes: 1 addition & 5 deletions src/resources/views/posts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ class="banner-image">
<i class="fas fa-clock"></i>
{{ \App\Http\Controllers\PostController::generateReadingTime($post) }} minutes
<i class="fas fa-tag"></i>
@if (isset($post->category->category))
{{ $post->category->category }}
@else
{{ 'Uncategorized' }}
@endif
{{ $post->category->category }}
</p>
<p>
<?php $strippedPost = preg_replace("/[^0-9a-zA-Z_.!?' \r\n+]/", '', $post->post); ?>
Expand Down

0 comments on commit f1a719a

Please sign in to comment.