PHP code example of whilesmart / eloquent-brands

1. Go to this page and download the library: Download whilesmart/eloquent-brands 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/ */

    

whilesmart / eloquent-brands example snippets


use Whilesmart\Brands\Traits\HasBrands;

class Workspace extends Model
{
    use HasBrands;
}

$workspace->brands()->create([
    'owner_type' => Workspace::class,
    'owner_id'   => $workspace->id,
    'name'    => 'Maison Amani SARL',
    'email'   => '[email protected]',
    'phone'   => '+237 690 00 04 12',
    'address' => '12 Market St, Douala',
    'website' => 'https://amani.africa',
    'tax_id'  => 'M029817',
    'is_default' => true,
    'colors'  => [
        ['name' => 'Primary', 'value' => '#0B0D07'],
        ['name' => 'Accent',  'value' => '#2E3B8D'],
    ],
]);

$workspace->brands;          // every brand kit
$workspace->defaultBrand;    // the default brand used on documents
$workspace->defaultBrand->assets; // its image assets (Files)

$logo = $brand->assetsByRole('logo')->first();
$logo?->url; // public URL of the asset

php artisan vendor:publish --tag=brands-config