Skip to content

Commit addbc6d

Browse files
committed
Add disableAll method to grid actions
1 parent 9015cf1 commit addbc6d

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/Grid/Displayers/Actions.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ class Actions extends AbstractDisplayer
2828
*/
2929
protected $resource;
3030

31+
/**
32+
* Disable all actions.
33+
*
34+
* @var bool
35+
*/
36+
protected $disableAll = false;
37+
3138
/**
3239
* Append a action.
3340
*
@@ -114,6 +121,18 @@ public function disableEdit(bool $disable = true)
114121
return $this;
115122
}
116123

124+
/**
125+
* Disable all actions.
126+
*
127+
* @return $this
128+
*/
129+
public function disableAll()
130+
{
131+
$this->disableAll = true;
132+
133+
return $this;
134+
}
135+
117136
/**
118137
* Set resource of current resource.
119138
*
@@ -147,6 +166,10 @@ public function display($callback = null)
147166
$callback->call($this, $this);
148167
}
149168

169+
if ($this->disableAll) {
170+
return '';
171+
}
172+
150173
$actions = $this->prepends;
151174

152175
foreach ($this->actions as $action) {

src/Grid/Displayers/DropdownActions.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function disableEdit(bool $disable = true)
155155
/**
156156
* @param null|\Closure $callback
157157
*
158-
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
158+
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View|string
159159
*/
160160
public function display($callback = null)
161161
{
@@ -165,6 +165,10 @@ public function display($callback = null)
165165
$callback->call($this, $this);
166166
}
167167

168+
if ($this->disableAll) {
169+
return '';
170+
}
171+
168172
$this->prependDefaultActions();
169173

170174
$actions = [

0 commit comments

Comments
 (0)