PHPackages                             it-devgroup/laravel-banner-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. it-devgroup/laravel-banner-api

ActiveLibrary[API Development](/categories/api)

it-devgroup/laravel-banner-api
==============================

Banner api for laravel/lumen

1.x-dev(4y ago)00MITPHPPHP ^7.4|^8.0

Since Dec 17Pushed 4y ago2 watchersCompare

[ Source](https://github.com/it-devgroup/laravel-banner-api)[ Packagist](https://packagist.org/packages/it-devgroup/laravel-banner-api)[ RSS](/packages/it-devgroup-laravel-banner-api/feed)WikiDiscussions 1.x Synced 4w ago

READMEChangelogDependencies (5)Versions (1)Used By (0)

Description
-----------

[](#description)

- extending models
- customizable table names
- extending the filter to get a list of models
- extending a query for listing models using the event system
- console command to add to cron to optimize table data
- console command to activate/deactivate banners by time
- binding banners to models
- trait class to implement the relationship between your model and banners

Install for Lumen
-----------------

[](#install-for-lumen)

**1.** Open file `bootstrap/app.php` and add new service provider

```
$app->register(\ItDevgroup\LaravelBannerApi\Provider\BannerServiceProvider::class);

```

Uncommented strings

```
$app->withFacades();
$app->withEloquent();

```

Added after **$app-&gt;configure('app');**

```
$app->configure('banner_api');

```

**2.** Run commands

For creating config file

```
php artisan banner:api:publish --tag=config

```

Check the table names in the config "**config/banner\_api.php**", in the **table** section

For creating migration file

```
php artisan banner:api:publish --tag=migration

```

For generate table

```
php artisan migrate

```

Install for laravel
-------------------

[](#install-for-laravel)

**1.** Open file **config/app.php** and search

```
    'providers' => [
        ...
    ]

```

Add to section

```
        \ItDevgroup\LaravelBannerApi\Provider\BannerServiceProvider::class,

```

Example

```
    'providers' => [
        ...
        \ItDevgroup\LaravelBannerApi\Provider\BannerServiceProvider::class,
    ]

```

**2.** Run commands

For creating config file

```
php artisan vendor:publish --provider="ItDevgroup\LaravelBannerApi\Provider\BannerServiceProvider" --tag=config

```

Check the table names in the config "**config/banner\_api.php**", in the **table** section

For creating migration file

```
php artisan banner:api:publish --tag=migration

```

For generate table

```
php artisan migrate

```

ENV variables
-------------

[](#env-variables)

File .env

All ENV variables is optionals

Main type for main image (default: empty value)

```
BANNER_API_IMAGE_MAIN_TYPE=main

```

Folder for all images (default: banners)

```
BANNER_API_IMAGE_FOLDER=banners

```

Optimization: clearing images without banner (default: true)

```
BANNER_API_OPTIMIZATION_IMAGE_CLEAR=1

```

Optimization: clearing attach models without banner (default: true)

```
BANNER_API_OPTIMIZATION_ATTACH_MODEL_CLEAR=1

```

Optimization: clearing statistic clicks (default: true)

```
BANNER_API_OPTIMIZATION_STATISTIC_CLICK_CLEAR=1

```

Optimization: total number of months for storing statistics on clicks (default: 12)

```
BANNER_API_OPTIMIZATION_STATISTIC_CLICK_MONTH=12

```

Custom model
------------

[](#custom-model)

if you need to extend the model, for example add methods or properties.

###### Step 1

[](#step-1)

Create custom model for BannerModel.

Example:

File: **app/CustomBannerModel.php**

Content:

```
