PHP code example of zachflower / ignorable-observers

1. Go to this page and download the library: Download zachflower/ignorable-observers 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/ */

    

zachflower / ignorable-observers example snippets


 namespace App;

use Illuminate\Database\Eloquent\Model;
use IgnorableObservers\IgnorableObservers;

class ExampleModel extends Model {
  use IgnorableObservers;
}

ExampleModel::ignoreObservableEvents();

ExampleModel::ignoreObservableEvents(['saved', 'created']);

ExampleModel::unignoreObservableEvents();

ExampleModel::unignoreObservableEvents(['saved']);

ExampleModel::ignoreObservableEvents('saved', 'created');

for ( $i = 0; $i <= 100; $i++ ) {
  ExampleModel::create([
    'data' => $i
  ]);
}

ExampleModel::unignoreObservableEvents();