Installation:
composer require baks-dev/drom-board
Ensure your project meets the PHP 8.4+ requirement and has baks-dev/core (≥7.4) installed.
Publish Config:
Publish the default configuration to config/drom-board.php:
php artisan vendor:publish --provider="BaksDev\DromBoard\DromBoardServiceProvider"
Basic Usage:
Register the board in your Laravel routes (routes/web.php):
Route::prefix('drom')->group(function () {
\BaksDev\DromBoard\Routes\DromBoardRoutes::register();
});
This auto-loads the default CRUD endpoints for listings, categories, and user interactions.
First Integration: Use the facade to fetch listings in a Blade template:
use BaksDev\DromBoard\Facades\DromBoard;
$listings = DromBoard::listings()->paginate(10);
Render with:
@foreach($listings as $listing)
<div>{{ $listing->title }} ({{ $listing->category->name }})</div>
@endforeach
Listing Management:
DromBoard::listing() builder to define rules and store listings:
$listing = DromBoard::listing()
->setTitle('Laravel Job')
->setCategoryId(1)
->setPrice(5000)
->save();
required, numeric) or extend via events:
DromBoard::extendValidation(function ($validator) {
$validator->addRule('custom', function ($attribute, $value) {
return strlen($value) > 10;
});
});
Category Hierarchy:
config/drom-board.php:
'categories' => [
1 => ['name' => 'Jobs', 'parent_id' => null],
2 => ['name' => 'Freelance', 'parent_id' => 1],
],
$categories = DromBoard::categories()->with('children')->get();
Search & Filtering:
$results = DromBoard::listings()
->where('title', 'like', '%Laravel%')
->where('price', '<', 10000)
->orderBy('created_at', 'desc')
->get();
DromBoard::extendQuery(function ($query, $request) {
if ($request->has('region')) {
$query->where('region_id', $request->region);
}
});
User Interactions:
DromBoard::on('listing.favorited', function ($listing, $user) {
// Log or notify
});
DromBoard::apiRoutes() for JSON responses:
Route::prefix('api/drom')->group(function () {
\BaksDev\DromBoard\Routes\DromBoardApiRoutes::register();
});
@component('drom-board::listing-card', ['listing' => $listing])
@endcomponent
php artisan test --group=drom-board
Mock dependencies with:
$this->partialMock(DromBoard::class, ['fetchCategories']);
PHP Version Mismatch:
laravel-shift/laravel-shift.Missing Core Dependency:
baks-dev/core (≥7.4) is mandatory. If omitted, the package throws ClassNotFoundException.composer require baks-dev/core:^7.4 before installing drom-board.Route Conflicts:
/drom/listings, /drom/categories) may clash with existing routes.'routes' => [
'prefix' => 'marketplace',
],
Translation Strings:
drom-board:: namespace for translations. Missing keys will show raw strings.php artisan vendor:publish --tag=drom-board-translations
Database Schema:
drom_listings, drom_categories, and drom_user_interactions exist.DromBoardServiceProvider:
public function boot()
{
$this->loadMigrationsFrom(__DIR__.'/../database/migrations');
}
DB::enableQueryLog();
$listings = DromBoard::listings()->get();
dd(DB::getQueryLog());
AppServiceProvider@boot():
DromBoard::on('*', function ($event) {
\Log::debug("DromBoard event: {$event->getName()}", $event->getData());
});
DromBoard::extendListingModel(function ($model) {
$model->addFillable(['custom_field']);
});
listing.paid event to sync with Stripe/PayPal:
DromBoard::on('listing.paid', function ($listing, $user, $amount) {
// Process payment
});
ListingResource to add OpenGraph tags:
DromBoard::extendResource('listing', function ($resource) {
$resource->meta = function () {
return [
'og:title' => $this->title,
'og:description' => $this->description,
];
};
});
DromBoard::extendTranslations(function ($translator) {
$translator->set('drom-board::listing.status.pending', 'Pending Review');
});
$categories = Cache::remember('drom.categories', 3600, function () {
return DromBoard::categories()->with('children')->get();
});
Storage facade to optimize image paths:
$listing->image_url = Storage::url($listing->image_path);
$listings = DromBoard::listings()->cursorPaginate(20);
How can I help you explore Laravel packages today?