PHP code example of chack1172 / laravel-single-save

1. Go to this page and download the library: Download chack1172/laravel-single-save 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/ */

    

chack1172 / laravel-single-save example snippets



...
use Chack1172\SingleSave\Eloquent\SingleSave;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use SingleSave;
}

class User extends Authenticatable
{
    use SingleSave;

    public function updateName($name)
    {
        $this->name = $name;
        $this->save();
    }

    public function updatePassword($password)
    {
        $this->password = $password;
        $this->save();
    }
}

// ...
$user->singleSave(function ($user) {
    $user->updateName('Marco Rossi');
    $user->updatePassword('1234');
});