PHP code example of usamamuneerchaudhary / adment

1. Go to this page and download the library: Download usamamuneerchaudhary/adment library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

usamamuneerchaudhary / adment example snippets


use Usamamuneerchaudhary\Adment\AdmentPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ...
        ->plugin(AdmentPlugin::make());
        // ->plugin(AdmentPlugin::make()->settingsPage(false)) to hide settings
        // ->plugin(AdmentPlugin::make()->analyticsPage(false)) to hide analytics
}

'locations' => [
    'not_set' => 'Not set',
    'homepage-banner' => 'Homepage banner',
    'sidebar' => 'Sidebar',
],

use Usamamuneerchaudhary\Adment\Facades\Ads;

Ads::registerLocation('footer', 'Footer')
    ->registerLocation('post-content', 'Below post content');

Ads::display('sidebar');                 // string of HTML
Ads::displayAds('HOMEPAGEBNNR');         // ?string
Ads::locationHasAds('sidebar');          // bool — for conditional layouts
Ads::getAd('HOMEPAGEBNNR');              // ?Ad model

// config/adment.php
'targeting' => [
    'country_resolver' => fn (\Illuminate\Http\Request $request): ?string => /* ... */,
    'unknown_country_behavior' => 'exclude_restricted',
],
bash
composer  vendor:publish --tag=adment-migrations
php artisan migrate

# optional
php artisan vendor:publish --tag=adment-config
php artisan vendor:publish --tag=adment-views