69 words, 1 min read

Stop all inbuilt model dispatch events for a specific model.

Advantage: applications will take less memory and improve performance.

Disadvantage: you can not use the Observer class for that model.

namespace App\Models;
class User extends Model
{
// First way: by using a static property
public static $dispatcher = null;
// Second way: in the constructor
public function __construct()
{
// if (!App::isLocal()) {
self::unsetEventDispatcher();
// }
}
}