如何使用Laravel中的方法创建函数

I need to create a function of this type, I do not know how it is done and I would like to learn

the function adds to the database, and receives some parameters

  event($user)->balande(2.00)->points(300);

example https://github.com/spatie/laravel-activitylog

activity('default')
   ->performedOn($anEloquentModel)
   ->causedBy($user)
   ->withProperties(['customProperty' => 'customValue'])
   ->log('Look, I logged something');

It's actually quite simple : the first function returns an object instance, and subsequent method calls are applied to this instance (they all return $this, allowing you to chain other method calls afterwards). Have a look at https://en.wikipedia.org/wiki/Fluent_interface

<?php

class Thing{
  public function doThat(){
      // [do something interesting in this object]

      return $this;
  }

  public function doSomethingElse(){
      // [do something interesting in this object]

      return $this;
  }
}

function Something(){
    return new Thing();
}

Something()->doThat()->doSomethingElse();