Touch parent updated_at in Laravel
Touch parent updated_at in Laravel
With this article, we’ll look at some examples of how to address the "Touch parent updated_at in Laravel" problem.
It will help you to update the updated_at column data of the parent table while updating the data of the child table. Like we make a comment on a specific post and we want to update the updated_at column of the related (post) records of the posts table then it will help you to do so-
Add touch property to child model to update the parent relationship to renew
--PATH app\Models\Comment.phpclass Comment extends Model { protected $touches = ['post']; }
It will update the updated_at column of the related record of the posts table if you make a comment on this particular post.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- How to display HTML tags In Laravel blade
- Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0"
- Docker important commands to run laravel application with docker
- How to get only time from created_at in laravel
- Wheredate in laravel not working
- Setup laravel project with docker
- How to create laravel project using composer
- Laravel 11 step by step instructions to upload file in storage directory and display in blade file
- Composer\Exception\NoSslException
- Database transactions in laravel
- Get all users except the followings users in overtrue laravel-follow
- Get count of filter data, while return a small set of records
- How to display a specific word from a string in laravel
- Laravel 11 project setup on localhost using breeze with blade step by step
- How to remove package from laravel
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- Attempt to read property "avatar" on null in Laravel
- Laravel clone model
- Create project table with model and migration
- Input file with max size validation in laravel
- How to access the nth object from Laravel collection object ?
- How to check column value of a record is null or not in laravel
- How to fetch single row data from database in laravel
- Method Illuminate\Events\Dispatcher::fire does not exist
- Illuminate\Database\QueryException could not find driver