Solved

Laravel tracking what was changed.

Posted on 2016-08-17
3
52 Views
1 Endorsement
Last Modified: 2016-08-17
I am a simple form with a few field displaying a person's contact information and when they edit it, I send the information out with ajax, is there a way with laravel that I can track what was the original form vs just the new information that is being sent out?
1
Comment
Question by:rivkamak
  • 2
3 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Great question!  There is a general design pattern used for things like this.  You never replace  a value in the contact information table.  Instead, you just append  the new values to the end of the table by adding a new row.  The result is a historical record of all changes.

When you want the most current value, your query uses something like ORDER BY id  DESC LIMIT 1.

When you want the historical perspective (to track changes) your query uses ORDER BY id  DESC.  This returns a 1-or-more results collection, and you can iterate through it to find the changes.
0
 

Author Comment

by:rivkamak
Comment Utility
Let's say, I have a phone number
111-111-1111
and the user comes in and change it to
222-222-2222

i want to send a proc out notification to the manager that someone changed their phone number
old number : is ____
new number is  $_POST['number']

is there a way to pull what was there before?
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
Not sure of the best "Laravel way" to do that (active record design should make this easy), but "in the raw" you might use a SELECT query to get the existing number, then use an INSERT query to add the new number from $_POST.  That would give you variables with both the old and new numbers and you can send the notification at that point.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now