Menu
  • HOME
  • TAGS

Laravel 4.2 how to determine if model is soft delete or force delete

laravel,cascading-deletes,soft-delete

The model has a property forceDeleting. Which will either be true or false: if($invoice->forceDeleting){ //do in case of force delete } else { //do in case of soft delete } Note that this property is only available when using the SoftDeletingTrait. So be careful to use this in some kind...

Physical delete a model which is enabled softdelete in laravel5?

php,mysql,laravel,laravel-5,soft-delete

Of course there is. Use forceDelete method instead of just delete. Keep in mind, forceDelete is only available if you use the SoftDeletes trait. Example $instance->delete() //This is a soft delete $instance->forceDelete() // This is a 'hard' delete More info here (scroll down to Permanently Deleting Models)...

Is it possible to perform “future” soft delete in laravel?

laravel,eloquent,soft-delete

Laravel only checks if deleted_at is not NULL. SoftDeletingScope: public function apply(Builder $builder) { $model = $builder->getModel(); $builder->whereNull($model->getQualifiedDeletedAtColumn()); $this->extend($builder); } You can change that by creating your own SoftDeletingScope and SoftDeletingTrait (it's called SoftDeletes in Laravel 5). trait MySoftDeletingTrait { use Illuminate\Database\Eloquent\SoftDeletingTrait; public static function bootSoftDeletingTrait() { static::addGlobalScope(new MySoftDeletingScope); }...

Soft deleting with Sentry 2 and Laravel 4.2

php,laravel,sentry,cartalyst-sentry,soft-delete

So, actually the solution was pretty simple. When working with Sentry, you're not using the Eloquent model that comes pre-configured with Laravel, but rather Cartalyst's own model. So what I needed to do was get the soft deleting declaration inside the Sentry user model under /vendor/cartalyst/sentry/src/Cartalyst/Sentry/Users/Eloquent/User.php instead of the one...

Cascading foreign key soft delete flag through update trigger in SQL Server

sql-server,entity-framework,triggers,cascade,soft-delete

From the relational point of view, your PKs are not valid, because there is a subset of it which is a valid PK itself (the Id column). It will also allow to have two rows with the same Id, but one deleted and one not (which I presume is not...

Logical delete at a common place in hibernate

java,hibernate,soft-delete

Try to replace the code in setIsActive method with: public void setIsActive(Boolean isActive) { this.isActive = isActive; } in your code the use of variable name without this could be ambiguos... I think you should also add @MappedSuperclass annotation to your abstract class to achieve field inheritance....

Laravel QueryException bypassing try-catch?

php,exception,laravel,php-5.3,soft-delete

Your $contact->forceDelete(); will call the method in Illuminate\Database\Eloquent\Model which has the following code: public function forceDelete() { $softDelete = $this->softDelete; // We will temporarily disable false delete to allow us to perform the real // delete operation against the model. We will then restore the deleting // state to what...

MySQL check before soft delete

mysql,foreign-keys,constraints,soft-delete

This should work if you create the active_view as you said you could. Just add the active flags of all the related tables into the foreign_active column, and you should be good to go. CREATE TRIGGER before_update_student BEFORE UPDATE ON student FOR EACH ROW BEGIN IF NEW.active = 0 AND...

Disallow Soft deleted User to log in using Auth in laravel 4

php,authentication,laravel,laravel-4,soft-delete

You can use the code provided on the Laravel documentation, where you would replace active => 1 with deleted_at => null http://laravel.com/docs/4.2/security#authenticating-users if (Auth::attempt(array('email' => $email, 'password' => $password, 'active' => 1))) { // The user is active, not suspended, and exists. } ...

filtered index or indexed view for Soft-delete with deleteAt dateTime column?

sql-server,web-applications,soft-delete,indexed-view,filtered-index

Instead of having one Datetime column to handle soft deletion, I would use two columns . ColumnName Data Type Deleted BIT DEFAULT(0) DeletedAt DateTime And create a Filtered Index on the Deleted column something WHERE Deleted = 0. The reason is, data with soft deleted rows we mostly only return...

laravel soft delete using a form

laravel,eloquent,soft-delete

Well you've set your two forms to use the PATCH and DELETE method but your routes are set to POST (Route::post). You can either change the routes: Route::patch('/admin/user/{resource}/delete', array('as' => 'admin.user.delete', 'uses' =>'[email protected]')); Route::delete('/admin/user/{resource}/restore', array('as' => 'admin.user.restore', 'uses' =>'[email protected]')); Or remove the method in your forms (it will default to...