(feature request) Guarded and fillable properties for mass assignment.
See original GitHub issueI really like being able to use mass assignment but also be able to protect certain columns from being updated.
In the style of: http://laravel.com/docs/eloquent#mass-assignment
Guarded properties that can be updated via mass assignment:
module.exports = function(bookshelf) {
return bookshelf.Model.extend({
tableName: 'account_benefits',
fillable: ['name', 'description']
});
};
OR
Guarded properties that can be updated via mass assignment:
module.exports = function(bookshelf) {
return bookshelf.Model.extend({
tableName: 'account_benefits',
guarded: ['id', 'created_at', 'updated_at', 'deleted_at']
});
};
var input = res.body;
new db.accountBenefit({ id: accountBenefitId })
// In this case input contains id, name, description, and created_at.
// Only name and description get new values.
.save(input)
.then(function(accountBenefit) {
res.json({ accountBenefit: accountBenefit });
});
});
Maybe a new method for it (fill?):
new db.userGoal({
id: userGoalId,
account_id: request.auth.credentials.account.id
})
.fill(request.payload)
.then(function(userGoal) {
reply({ userGoal: userGoal });
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Laravel Mass Assignment, Guarded or Fillable?
Guarded is the reverse of fillable. If fillable specifies which fields to be mass assigned, guarded specifies which fields are not mass assignable....
Read more >What does "Mass Assignment" mean in Laravel?
Guarded is the reverse of fillable. If fillable specifies which fields to be mass assigned, guarded specifies which fields are not mass ...
Read more >Laravel mass assignment and fillable vs guarded - Tallpad
In this video we'll take a look over mass assignment in Laravel and whether to go with $fillable or $guarded when protecting against...
Read more >$fillable and $guarded don't work when use update()? #39305
Hi, I use Laravel 8.41.0 and I have a question: Why $fillable and $guarded don't work when I use update() to update data?...
Read more >When mass assignment is happening? - Laracasts
Hi, i got a question. I got confused by mass assignment and fillable attribute. In my controller, in store method i have something...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@marco-fiset Nobody is working on this feature presently. I’d suggest building out a plugin if you need it.
The project leadership of Bookshelf recently changed. In an effort to advance the project we close all issues older than one year.
If you think this issue needs to be re-evaluated please post a comment on why this is still important and we will re-open it.
We also started an open discussion about the future of Bookshelf.js here https://github.com/bookshelf/bookshelf/issues/1600. Feel free to drop by and give us your opinion. Let’s make Bookshelf great again