PHP code example of angus-mcritchie / blade-boost-directive

1. Go to this page and download the library: Download angus-mcritchie/blade-boost-directive 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/ */

    

angus-mcritchie / blade-boost-directive example snippets


// get the real cache key @boost uses
$key = \AngusMcRitchie\BladeBoostDirective\Boost::prefix('my-key');

cache()->store('array')->forget($key);

return [

    /**
     * Enable or disable the package.
     * If disabled, the package will not register any Blade directives.
     */
    'enabled' => env('BLADE_BOOST_ENABLED', true),

    /**
     * The default cache store to use.
     * This is used when no cache store is specified in the directive.
     */
    'default_cache_store' => env('BLADE_BOOST_DIRECTIVE_DEFAULT_CACHE_STORE', 'array'),

    /**
     * The prefix to use for cache keys.
     * This is used to avoid key collisions with other packages or parts of your application.
     */
    'prefix' => env('BLADE_BOOST_DIRECTIVE_PREFIX', 'blade-boost-directive.'),
];
blade
@foreach($posts as $post)
    <x-card>
        <x-link href="{{ route('post.show', $post) }}">
            <x-image src="{{ $post->image }}" />
        </x-link>
        <x-card.body>
            <x-heading as="h3">{{ $post->title }}</x-heading>
            <x-text>{{ $post->description }}</x-text>
        </x-card.body>
        <x-badge class="absolute top-0 left-0">{{ $post->author }}</x-badge>
        <x-card.footer>
            <x-button href="{{ route('post.show', $post) }}">
                Read More
            </x-button>
        </x-card.footer>
    </x-card>
@endforeach
blade
@foreach($posts as $post)
    @boost([
        'key' => 'post-card',
        'replace' => [
            '{title}' => $post->title,
            '{name}' => $post->name,
            '{url}' => route('post.show', $post),
            '{image}' => $post->image,
            '{author}' => $post->author,
            '{description}' => $post->description
        ]
    ])
        <x-card>
            <x-link href="{url}">
                <x-image src="{image}" />
            </x-link>
            <x-card.body>
                <x-heading as="h3">{title}</x-heading>
                <x-text>{description}</x-text>
            </x-card.body>
            <x-badge class="absolute top-0 left-0">{author}</x-badge>
            <x-card.footer>
                <x-button href="{url}">
                    Read More
                </x-button>
            </x-card.footer>
        </x-card>
    @endboost
@endforeach
blade
@foreach($posts as $post)
    @boost([
        'key' => ['post-card', $post->show_author_badge], // changed
        'replace' => [
            '{name}' => $post->name,
            '{author}' => $post->author,
            '{url}' => route('post.show', $post),
        ]
    ])
        <x-card>
            <x-heading as="h3">{title}</x-heading>

            @if($post->show_author_badge)
                <x-badge class="absolute top-0 left-0">{author}</x-badge>
            @endif

            <x-button href="{url}">
                Read More
            </x-button>
        </x-card>
    @endboost
@endforeach
bash
php artisan vendor:publish --tag="blade-boost-directive-config"