What is "touches"? Well, anyone familiar with Linux/Unix is going to be familiar with the concept of "touching" a file. Touching a file sets the "last modified" timestamp (or creates the file if it doesn't exist). Knowing when a file was last modified can be very important for version control. Laravel has something similar for its model relations. For example, lets say there is a club with many members. When a member joins, leaves or gets a new role in the club, you might contend that the club has changed. In terms of Laravel, you would want the club table's "updated_at" timestamp to reflect that change. Enter the "touches" property... To make the magic happen in Laravel, you simply need to define the parent relationship and add it to the touches property like so: <?php class Club extends Model { /** * Touches (touch parent model when this model changes) */ protected $touches = [ ...
My developer blog! For sharing my solutions to issues, likes, dislikes and anything else related to web development. Specifically discusses Salesforce (Apex & administration), PHP/Laravel, CSS, jQuery and Bootstrap and related libraries and plugins.