Comments (4)
@a-ssassi-n You can use pivot feature of laravel: https://laravel.com/docs/5.7/eloquent-relationships#updating-many-to-many-relationships
// follow
$user->follow($other, ['is_approved' => false]); // maybe default as false
//approve
$user->followers()->updateExistingPivot($other->id, ['is_approved' => true]);
// access pivot attributes
foreach ($user->followers as $follower) {
$follower->pivot->is_approved;
}
from laravel-follow.
I will refactor this project.
from laravel-follow.
Hi I feel like i need to update this issue for a specific issue I'm having.
I need to grab the is_approved
parameter for example. Updating is fine but on my backend I'm unable to query this relationship I feel like the following is the reason:
https://github.com/overtrue/laravel-follow/blob/master/src/Traits/CanFollow.php#L108
For example doing the following will return null:
//Find if user 1 is following user 2 and if they are approved
>>> User::find(1)->followings(User::class)->wherePivot('followable_id',2)->first()->pivot->is_approved
>>> null
Is there a way we can override or add in additional withPivot
attributes?
from laravel-follow.
So adding that column right now is not convenient until you fix the bug? @overtrue
from laravel-follow.
Related Issues (20)
- Getting same error in Model all the time HOT 7
- Error Traits HOT 9
- Get List of Followings users HOT 1
- config key typo HOT 2
- Question: How to send notification/email to user when they have a new follower? HOT 11
- get General error: 1 no such table: followables error HOT 12
- $user->followings not working properly HOT 6
- how to recover data from the "following" user? HOT 2
- Feature Request: Followers you know HOT 9
- Extending the model
- Trait "Overtrue\LaravelFollow\Traits\Followable" not found HOT 2
- Update for Laravel 10
- [ERROR] After running command - SSL Issues HOT 3
- php artisan vendor:publish does not publish the migration or config HOT 3
- Error after upgrade to 5.1.0 HOT 14
- wrong sample code in readme.
- Can't Get Following Model Data HOT 1
- getting "general error" when attempting to use UUIDs HOT 2
- sorry. please delete this issue
- has_followed没有实现 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-follow.