Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

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, http://laravel.io/forum/01-12-2015-custom-soft-delete-column?p...

Hope that helps

0

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.

0

Thanks zaalbarxx, I totally missed that.

0

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.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

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

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.