restored_at timestamp?

Is it possible to add a restored_at timestamp for restoring soft deleted records?

TerrePorter replied 4 years ago Solution

I looked in to something similar to this just a bit ago, you can attach to the deleted and deleting events but I'm not finding any event for restoring, so for now it would likely be attaching to the updating event and checking for the deleted_at being set to null and then set your timestamp then.

Here is the other topic,

Hope that helps

zaalbarxx replied 4 years ago

In Illuminate\Database\Eloquent\SoftDeletingTrait you can find

	public function restore()
		// If the restoring event does not return false, we will proceed with this
		// restore operation. Otherwise, we bail out so the developer will stop
		// the restore totally. We will clear the deleted timestamp and save.
		if ($this->fireModelEvent('restoring') === false)
			return false;

		$this->{$this->getDeletedAtColumn()} = null;

		// Once we have saved the model, we will fire the "restored" event so this
		// developer will do anything they need to after a restore operation is
		// totally finished. Then we will return the result of the save call.
		$this->exists = true;

		$result = $this->save();

		$this->fireModelEvent('restored', false);

		return $result;

So it looks like there is an restoring and restored event that is being fired.

TerrePorter replied 4 years ago

Thanks zaalbarxx, I totally missed that.

Steve-45 replied 3 years ago

If you are looking for simple way to backup then try Ahsay Software. Ahsay Backup software is the best backup solution has it all real-time archiving, unlimited versions of files, fully automatic and it designed for manage service provider to provide online backup service to their users. I'm really happy with it. You can also try this.

Sign in to participate in this thread!

We'd like to thank these amazing companies for supporting us