Fresh code drop

Read the affected row count

PHP

Original CodeSnap example inspired by Laravel News. Source: https://laravel-news.com/eloquent-tips-tricks

PHP
CodeSnap // free canvas

Read the affected row count

<?php

$updated = Product::query()
    ->whereNull('category_id')
    ->update(['category_id' => $fallbackCategoryId]);

logger()->info("Updated {$updated} products");

// Further reading: https://laravel-news.com/eloquent-tips-tricks

Turn your code into a post.Five templates are free—no account needed.

Remix this snap