mlezcano1985 / laravel-pivot-soft-deletes Goto Github PK
View Code? Open in Web Editor NEW(DEPRECATED) Soft delete Eloquent pivot models using Laravel SoftDeletes trait
License: MIT License
(DEPRECATED) Soft delete Eloquent pivot models using Laravel SoftDeletes trait
License: MIT License
I am wondering if you are planning to add support to Laravel 6 #7
The intermediate pivot table doesn't do soft delete when using sync(). For example(),
public function dept()
{
return $this->belongsToMany('App\Dept', 'user_dept', 'user_id', 'dept_id');
}
User is in many to many relation on Dept. Both User and Dept use SoftDeletes, PivotSoftDeletes;
$user = User::find(1);
$user->dept()->sync([3, 2, 8, 4]); // --> this will attach dept id, 3, 2, 8, 4 to the pivot table for user id 1
$user->dept()->sync([3, 2, 9, 4]); // --> this should put delete_at for dept id 8 and add row with dept id 9 in the pivot table
But after I run it, it instead deleted dept id 8 and add dept id 9 in the pivot table.
Note: I use laravel 5.6
Maybe I'm misunderstanding what this is for. Lets say an event has a many to many relationship with users. This relation is "attendingUsers".
If I get a user through that relation and then detach it, I see deleted_at is populated in the pivot table. But the issue is when you run that relation again, you still get that user.
$event->attendingUsers->count();
=> 20
>>> $event->attendingUsers->first()->detach();
=> 1
>>> $event->attendingUsers->count();
=> 20
Seem like it would be considerably more useful if the relations would prevent associates with soft deleted relations. Am I missing something?
Can you help with the last change you made to be visible in packagist ?
Support for Lavavel 6.0
Thanks a lot !
$deletedAt is mistyped in methods, detachBelongsToManySoftDelete, and detachPivotSoftDelete
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.