<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
roundly-consulting / package-toolkit-for-laravel example snippets
use RoundlyConsulting\PackageToolkit\Concerns\RegistersBlueprintMacros;
use RoundlyConsulting\PackageToolkit\Package;
use RoundlyConsulting\PackageToolkit\PackageServiceProvider;
final class CommentsServiceProvider extends PackageServiceProvider
{
use RegistersBlueprintMacros;
public function configurePackage(Package $package): void
{
$package
->name('comments') // tags: comments-config, comments-migrations, …
->hasConfigFile()
->hasMigrations()
->hasTranslations()
->hasCommands([PruneCommentsCommand::class])
->contributesToAbout();
}
public function boot(): void
{
parent::boot();
$this->registerBlueprintMacros(); // morphKey(), ownerKey(), auditable(), …
}
}
use RoundlyConsulting\PackageToolkit\Enums\KeyType;
use RoundlyConsulting\PackageToolkit\Support\Config;
Schema::create('comments', function (Blueprint $table): void {
$table->id();
$table->morphKey('commentable', KeyType::fromConfig('comments.key_type')); // bigint, uuid or ulid pair
$table->text('body');
$table->auditable(); // timestamps + soft deletes
});
Config::integer('comments.per_page', 20, min: 1, max: 100); // '20' → 20; 'five' throws, never falls back
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.