PHP code example of aldeebhasan / laravel-cache-flusher

1. Go to this page and download the library: Download aldeebhasan/laravel-cache-flusher 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/ */

    

aldeebhasan / laravel-cache-flusher example snippets


 'mapping' => [
    'store_info'  =>  [ Product::class, Category::class ],
    'store_info.categories'  =>  [  Category::class ],
    'store_info.products'  =>  [  Product::class ],
 ]

 'mapping' => [
    '^(store\..+|mobile\..+)$'  =>  [ Product::class, Category::class ]
 ]

 'mapping' => [
    '^(.*\.products|.*\.categories)$'  =>  [ Product::class, Category::class,Attribute::class ]
 ]

// define the binding mapping function
class AppServiceProvider extends ServiceProvider
{

    public function boot()
    {
        //.... other boot methods
    
       CacheFlusher::setBindingFunction(
            function (string $bindingKey, Model $model): ?string {
                switch ($bindingKey) {
                    case "company_id":
                        return '1'; //$model->company_id
                    case "user_id":
                        return "2"; // $model->user_id;
                }
                return null;
            });
    }
}

'mapping' => [
    '^companies\.{company_id}\.stores' => [User::class],
    '^companies\.{company_id}\.mobiles\.{user_id}' => [User::class],
]

php artisan vendor:publish --tag=cache-flusher