yaroslawww / nova-ad-director
Laravel nova ad manager to display advertise on site.
Requires
- php: ^8.1
- illuminate/support: ^9.0|^10.0
- laravel/nova: ^4.0
- think.studio/nova-flexible-content: ^3.0|^4.0
- yaroslawww/laravel-ad-director: ^1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.16
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10.1
- psalm/plugin-laravel: ^2.8
- vimeo/psalm: ^5.11
This package is auto-updated.
Last update: 2024-12-06 14:14:50 UTC
README
Laravel nova ad manager to display advertise on site.
Installation
You can install the package via composer:
composer require yaroslawww/nova-ad-director # optional publish configs php artisan vendor:publish --provider="NovaAdDirector\ServiceProvider" --tag="config" # publish translations php artisan vendor:publish --provider="NovaAdDirector\ServiceProvider" --tag="lang"
Usage
- Package supports only predefined sizes. That why developer should firstly specify "global" sizes
- Inherit or add to nova AdConfiguration Resource
- Inherit or add to auth service provider AdConfigurationPolicy
- If app uses configuration with "creatable==false" then developer need create new locations
manually
php artisan nova-ad-director:ad-config:create <key-name> <location-name>
- Then configure ads in your system
use NovaAdDirector\Facades\NovaAdDirector; class FrontpageController extends Controller { public function __invoke() { NovaAdDirector::prepareAds([ 'header' => NovaAdDirector::fallbackKey('header', 'frontpage'), 'medium-posts-list' => NovaAdDirector::fallbackKey('medium', 'list', 'frontpage'), 'footer-v2' => NovaAdDirector::fallbackKey('footer', 'frontpage'), ]); return view('frontpage'); } }
Key fallback search flow
In multiple situation good to have possibility to use same ad for multiple pages but with some specific ad on specific page, etc. Solution is using fallback flow:
Each key can be computed form multiple nested pointers and system will try to find parent key in case of child is empty.
For example site has multiple pages and multiple posts. That why different pages and posts will search keys like these:
header:page:frontpage
header:page:contact-us
header:post:12
header:post:654
each this keys will search fallbacks:
header:page:frontpage
=>header:page
=>header
header:page:contact-us
=>header:page
=>header
header:post:12
=>header:post
=>header
header:post:654
=>header:post
=>header
Administrator in admin can specify only header
configuration and in any moment add some specific AD item like
header:page:contact-us
to override ad only for contact us page or header:post
to use specific ad only on posts.
Override default fallback separator
class AppServiceProvider extends ServiceProvider { public function register() { \NovaAdDirector\NovaAdDirector::setFallbackKeyConnector('/'); } }