---
title: "Installation — Advertisements for Laravel | Roundly"
description: "Install via Composer, publish and run the migrations (plus media-library’s, always, and sluggable’s for slug history), then optionally the config and view."
url: https://roundly-consulting.com/open-source/docs/advertisements-for-laravel/installation
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Advertisements for Laravel](https://roundly-consulting.com/open-source/docs/advertisements-for-laravel.md)

# Installation

Require the package with Composer. The service provider and the Advertisements facade alias are auto-discovered. The Roundly packages it builds on — media-library, geolocation, sluggable, money, enums and package-toolkit — install as Composer dependencies, and their service providers are auto-discovered too:

```bash
composer require roundly-consulting/advertisements-for-laravel

php artisan vendor:publish --tag="advertisements-migrations"
php artisan migrate
```

The migrations are publish-only — the package never loads them itself, so php artisan migrate runs exactly the seven files you published, timestamped in dependency order: categories → placements → advertisements → the advertisement\_placement pivot → advertisement\_events → the targeting and country\_code additions.

## Sibling migrations

Creatives are stored in media-library-for-laravel’s media table, and its migrations are required even if you never upload one: render() checks the media table for a creative before it falls back to the text ad, so without it rendering any ad throws a QueryException. Slug history (off by default) needs sluggable-for-laravel’s slug\_history table:

```bash
# Required — render() looks creatives up in media-library-for-laravel's media table
php artisan vendor:publish --tag="media-migrations"

# Only with advertisements.slugs.history on — sluggable-for-laravel's slug_history table
php artisan vendor:publish --tag="sluggable-migrations"

php artisan migrate
```

The price column comes from money-for-laravel’s $table->money() macro — a decimal(38,0) minor-unit amount plus a currency column sized by money.schema.currency\_length — so money’s service provider must be registered when you migrate. Auto-discovery takes care of it.

## Before you migrate

- advertisements.key\_type — set it to uuid or ulid when your author models use UUID/ULID keys. It decides the author morph column type and is read at migrate time, so every author model must share it; changing it later needs a migration of your own.
- Supported locales — the advertisements migration creates one unique slug index per locale sluggable-for-laravel reports at migrate time (sluggable.locales.supported, else app.locale + app.fallback\_locale). Set that list first.

Add a locale later and create its slug index with:

```bash
php artisan sluggable:indexes "RoundlyConsulting\Advertisements\Models\Advertisement"
```

## Optional publishing

The config file is optional — every key has a default and the common ones are env-backed:

```bash
php artisan vendor:publish --tag="advertisements-config"
```

Publish the text-ad Blade view to restyle the fallback rendered when an ad has no image creative:

```bash
php artisan vendor:publish --tag="advertisements-views"
# → resources/views/vendor/advertisements/text-ad.blade.php
```

| Tag | Publishes |
| --- | --- |
| `advertisements-migrations` | The seven migrations, timestamped on publish. |
| `advertisements-config` | config/advertisements.php. |
| `advertisements-views` | resources/views/vendor/advertisements/text-ad.blade.php. |

## Storage and geolocation

Creatives are stored through media-library-for-laravel — configure its media.disk and an image driver (gd or imagick) as that package documents. Geo features resolve viewer IPs through geolocation-for-laravel — configure its provider pipeline (MaxMind, IPinfo, …) there.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/advertisements-for-laravel.md)
