PHP code example of latevaweb / laravel-query-updater

1. Go to this page and download the library: Download latevaweb/laravel-query-updater 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/ */

    

latevaweb / laravel-query-updater example snippets


'providers' => [
    // ...
    LaTevaWeb\QueryUpdater\QueryUpdaterServiceProvider::class,
];

use LaTevaWeb\QueryUpdater\QueryUpdater;

public function __invoke(Request $request, User $user) {
    QueryUpdater::for($user)
        ->updatedFields(['name'])
        ->save();
        
    // update
}

use LaTevaWeb\QueryUpdater\QueryUpdater;
use LaTevaWeb\QueryUpdater\KeepStored;

public function __invoke(Request $request, User $user) {
    QueryUpdater::for($user)
        ->updatedFields([
            KeepStored::field('name')
        ])
        ->save();
        
    // update
}