Set access for each item
See original GitHub issueSeems like there is no option for setting access for each item individually.
For example, I wanted to limit updating/editing/deleting access to the user who has created the post (or to users that have certain permissions).
I implemented backend verification like this:
public function update(UpdateRequest $request)
{
$this->denyIfNotParent($request->get('id'));
//...
}
public function edit($id)
{
$this->denyIfNotParent($id);
return parent::edit($id);
}
public function destroy($id)
{
$this->denyIfNotParent($id);
return parent::destroy($id);
}
public function denyIfNotParent($id)
{
if(accessLogicHere()){
abort(403);
}
}
But I couldn’t hide buttons (Edit, Delete).
Any suggestions?
Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:21 (14 by maintainers)
Top Results From Across the Web
Python - Access Set Items - W3Schools
You cannot access items in a set by referring to an index or a key. But you can loop through the set items...
Read more >Loops For Each | Access All In One
Demonstrating The For Each Loop with An Array. We can use the For Each loop over a standard array. Sub forEachArray() Dim element...
Read more >Learn to build an expression - Microsoft Support
Set default values for a table field. You can use an expression to specify a default value for a field in a table...
Read more >Access an element in a set? - c++ - Stack Overflow
You have to access the elements using an iterator. set<int> myset; myset.insert(100); int setint = *myset.begin();. If the element you want ...
Read more >Set Access Inherited for all Items - Smart DXL
This simple script allows you to set the access rights to inherited for all items below the current folder. This may be useful...
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
Hi! I was looking for the same behaviour. In version 4.1, I had to do:
Denying to all and allowing just when condition is true was not working. Sorry, my knowledge of the package is not so deep yet to explain why 😃
Regards!
I managed permission for each record by doing the following steps:
Restricting access to edit records for all users except administrator by adding to the setup method of the task controller:
Opening access to the owner of the record by overriding the edit and update methods:
In this way only the records of the logged user have an edit button, unless the user has the appropriate permissions. Also the routes are protected.