src/Traits/Auditable.php
public static function bootAuditable()
    {
        static::creating(function (Model $model) {
            $model->created_by_id || $model->created_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
            $model->created_by_type || $model->created_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass();

            $model->updated_by_id || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
            $model->updated_by_type || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass();
        });

        static::updating(function (Model $model) {
            $model->isDirty('updated_by_id') || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
            $model->isDirty('updated_by_type') || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass();
        });
    }
public static function bootAuditable()
    {
        static::creating(function (Model $model) {
            $model->created_by_id || $model->created_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
            $model->created_by_type || $model->created_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass();

            $model->updated_by_id || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
            $model->updated_by_type || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass();
        });

        static::updating(function (Model $model) {
            $model->isDirty('updated_by_id') || $model->updated_by_id = optional(auth()->guard(request()->route('guard'))->user())->getKey();
            $model->isDirty('updated_by_type') || $model->updated_by_type = optional(auth()->guard(request()->route('guard'))->user())->getMorphClass();
        });
    }
public static function bootAuditable ( ) { static :: creating ( function ( Model $ model ) { $ model -> created_by_id || $ model -> created_by_id = optional ( auth ( ) -> guard ( request ( ) -> route ( 'guard' ) ) -> user ( ) ) -> getKey ( ) ; $ model -> created_by_type || $ model -> created_by_type = optional ( auth ( ) -> guard ( request ( ) -> route ( 'guard' ) ) -> user ( ) ) -> getMorphClass ( ) ; $ model -> updated_by_id || $ model -> updated_by_id = optional ( auth ( ) -> guard ( request ( ) -> route ( 'guard' ) ) -> user ( ) ) -> getKey ( ) ; $ model -> updated_by_type || $ model -> updated_by_type = optional ( auth ( ) -> guard ( request ( ) -> route ( 'guard' ) ) -> user ( ) ) -> getMorphClass ( ) ; } ) ; static :: updating ( function ( Model $ model ) { $ model -> isDirty ( 'updated_by_id' ) || $ model -> updated_by_id = optional ( auth ( ) -> guard ( request ( ) -> route ( 'guard' ) ) -> user ( ) ) -> getKey ( ) ; $ model -> isDirty ( 'updated_by_type' ) || $ model -> updated_by_type = optional ( auth ( ) -> guard ( request ( ) -> route ( 'guard' ) ) -> user ( ) ) -> getMorphClass ( ) ; } ) ; }
Boot the Auditable trait for the model.

@return void
Boot the Auditable trait for the model .