Install via Composer:
composer require answear/luigis-box-bundle
Publish the configuration (if needed):
php artisan vendor:publish --provider="Answear\LuigisBoxBundle\LuigisBoxServiceProvider"
The package now includes a GUID field in API responses (added in v5.3.0), which can be useful for client-side tracking or unique identifier needs. Check the default response structure in config/luigis-box.php for the new field.
First Use Case: Enable GUIDs in responses by setting:
'include_guid' => true,
in the config. Verify by inspecting API responses—each resource will now include a guid field.
The GUID field is automatically appended to all serializable responses (e.g., Eloquent models, collections). Use this for:
event('track', ['guid' => $response->guid])).Model::updateOrCreate(['guid' => $request->guid], [...])).Override the GUID generation logic by binding a custom generator to the container:
$this->app->bind(\Answear\LuigisBoxBundle\Contracts\GuidGenerator::class, function () {
return new \YourApp\CustomGuidGenerator();
});
Extend Laravel’s JsonResource to explicitly include the GUID:
public function toArray($request)
{
return array_merge(parent::toArray($request), [
'guid' => $this->resource->guid ?? strtolower(Ramsey\Uuid\Uuid::uuid4()->toString()),
]);
}
$guid = app(\Answear\LuigisBoxBundle\Contracts\GuidGenerator::class)->generate();
guid column to your tables and hydrate it via model events:
protected static function booted()
{
static::creating(function ($model) {
$model->guid = strtolower(Ramsey\Uuid\Uuid::uuid4()->toString());
});
}
composer.json if relying on this feature.include_guid is true in config and that your response is using the bundle’s default serializer (e.g., JsonResource).GuidGenerator::generate() and returns unique values.resources/views/vendor/luigis-box/partials/response.blade.php).$request->validate(['guid' => 'uuid']);
How can I help you explore Laravel packages today?