algowrite/laravel-help-center
Laravel help center package for Laravel apps. Add a general-purpose support knowledge base with pages/articles and help content for common use cases, suitable for building simple self-service documentation and FAQ-style sections.
Installation
composer require algowrite/laravel-help-center
php artisan vendor:publish --provider="Algowrite\HelpCenter\HelpCenterServiceProvider"
php artisan migrate
config/help-center.php and resources/views/vendor/help-center/.Configuration
config/help-center.php with your preferred:
categories (default: ['General', 'Technical', 'Billing'])per_page (default: 10)enable_comments (default: true)moderation_required (default: false)First Use Case: Displaying Help Articles
routes/web.php:
use Algowrite\HelpCenter\Facades\HelpCenter;
Route::get('/help', [HelpCenter::class, 'index']);
php artisan help-center:seed
Managing Articles
// Create
HelpCenter::create(['title' => 'FAQ', 'content' => '...', 'category' => 'General']);
// Update
$article = HelpCenter::find(1);
$article->update(['content' => 'Updated...']);
// Delete
HelpCenter::destroy(1);
HelpCenter::where('category', 'Technical')->update(['is_published' => true]);
Displaying Data
@foreach(HelpCenter::published()->latest()->paginate(5) as $article)
<h3>{{ $article->title }}</h3>
<p>{{ Str::limit($article->content, 100) }}</p>
@endforeach
api routes):
Route::apiResource('help-articles', \Algowrite\HelpCenter\Http\Controllers\HelpArticleController::class);
Comments System
enable_comments: true).hasMany relationship:
$article = HelpCenter::find(1);
$comments = $article->comments; // Polymorphic relationship
Search Functionality
HelpCenter::search('laravel')->get();
HelpCenter::where('content', 'like', '%laravel%')->get();
Route::middleware(['auth', 'admin'])->group(function () {
Route::resource('admin/articles', \Algowrite\HelpCenter\Http\Controllers\Admin\HelpArticleController::class);
});
resources/views/vendor/help-center/ and translate strings via Laravel’s localization.Migration Conflicts
articles table manually, reset migrations:
php artisan migrate:fresh --seed
php artisan help-center:seed to repopulate data after resets.Polymorphic Comments
commentable (articles, FAQs, etc.). Ensure your models use:
public function comments()
{
return $this->morphMany(\Algowrite\HelpCenter\Models\Comment::class, 'commentable');
}
commentable_id and commentable_type columns to the comments table will break polymorphic relationships.Caching Headaches
php artisan cache:clear
php artisan scout:flush "Algowrite\HelpCenter\Models\Article"
Route Caching
php artisan route:cache, ensure your help center routes are included in the cache or exclude them:
php artisan route:cache --exclude="help-center"
.env:
DB_LOG_QUERIES=true
resources/views/vendor/help-center/ to debug rendering issues.use Algowrite\HelpCenter\Rules\ValidCategory;
$request->validate([
'title' => 'required|max:255',
'content' => 'required',
'category' => ['required', new ValidCategory],
]);
Custom Fields
Article model to add custom attributes:
class Article extends \Algowrite\HelpCenter\Models\Article
{
protected $casts = [
'is_featured' => 'boolean',
];
}
Event Listeners
ArticleCreated):
namespace Algowrite\HelpCenter\Events;
class ArticleCreated
{
public $article;
}
EventServiceProvider:
protected $listen = [
ArticleCreated::class => [
\App\Listeners\NotifyAdmins::class,
],
];
API Resources
namespace App\Http\Resources;
use Algowrite\HelpCenter\Models\Article;
use Illuminate\Http\Resources\Json\JsonResource;
class HelpArticleResource extends JsonResource
{
public function toArray($request)
{
return [
'title' => $this->title,
'slug' => $this->slug,
'read_time' => $this->estimateReadTime(), // Custom method
];
}
}
Middleware
Route::middleware(['auth', 'verified'])->group(function () {
Route::resource('help', \Algowrite\HelpCenter\Http\Controllers\HelpController::class);
});
How can I help you explore Laravel packages today?