PHP code example of fico7489 / laravel-updated-related

1. Go to this page and download the library: Download fico7489/laravel-updated-related 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/ */

    

fico7489 / laravel-updated-related example snippets


$seller = Cache::remember('seller_' . $id, $minutes, function () use($id){
    return Seller::with(['orders', 'orders.items', 'addresses', 'zipCodes'])->find($id);
});

php artisan vendor:publish  --provider="Fico7489\Laravel\UpdatedRelated\Providers\UpdatedRelatedServiceProvider"

use Fico7489\Laravel\UpdatedRelated\Events\ModelChanged;

class TestListener
{
    public function handle(ModelChanged $event)
    {
        echo 'id=' . $event->getId();
        echo 'model=' . $event->getModel();
        echo 'environment=' . $event->getName();
    }
}

$users = User::whereIn('id', $ids);
foreach($users as $user){
    $user->update(['status' => 'ban']);
}