Skip to content

Commit 16f933e

Browse files
Add Gate facade to Blade tutorial (#72)
* Added Gate facade to blade tutorial * Update deleting-chirps.md * Update editing-chirps.md --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent f56a1ce commit 16f933e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

resources/docs/blade/deleting-chirps.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use App\Models\Chirp;
5656
use Illuminate\Http\RedirectResponse;
5757
use Illuminate\Http\Request;
5858
use Illuminate\Http\Response;
59+
use Illuminate\Support\Facades\Gate;
5960
use Illuminate\View\View;
6061
// [tl! collapse:end]
6162
class ChirpController extends Controller
@@ -106,7 +107,7 @@ class ChirpController extends Controller
106107
*/
107108
public function edit(Chirp $chirp): View
108109
{
109-
$this->authorize('update', $chirp);
110+
Gate::authorize('update', $chirp);
110111

111112
return view('chirps.edit', [
112113
'chirp' => $chirp,
@@ -118,7 +119,7 @@ class ChirpController extends Controller
118119
*/
119120
public function update(Request $request, Chirp $chirp): RedirectResponse
120121
{
121-
$this->authorize('update', $chirp);
122+
Gate::authorize('update', $chirp);
122123

123124
$validated = $request->validate([
124125
'message' => 'required|string|max:255',
@@ -136,7 +137,7 @@ class ChirpController extends Controller
136137
public function destroy(Chirp $chirp): RedirectResponse// [tl! add]
137138
{
138139
//
139-
$this->authorize('delete', $chirp);// [tl! remove:-1,1 add:start]
140+
Gate::authorize('delete', $chirp);// [tl! remove:-1,1 add:start]
140141

141142
$chirp->delete();
142143

resources/docs/blade/editing-chirps.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ use App\Models\Chirp;
140140
use Illuminate\Http\RedirectResponse;
141141
use Illuminate\Http\Request;
142142
use Illuminate\Http\Response;
143+
use Illuminate\Support\Facades\Gate;
143144
use Illuminate\View\View;
144145
// [tl! collapse:end]
145146
class ChirpController extends Controller
@@ -192,7 +193,7 @@ class ChirpController extends Controller
192193
public function edit(Chirp $chirp): View// [tl! add]
193194
{
194195
//
195-
$this->authorize('update', $chirp);// [tl! remove:-1,1 add:start]
196+
Gate::authorize('update', $chirp);// [tl! remove:-1,1 add:start]
196197

197198
return view('chirps.edit', [
198199
'chirp' => $chirp,
@@ -205,7 +206,7 @@ class ChirpController extends Controller
205206
public function update(Request $request, Chirp $chirp): RedirectResponse// [tl! add]
206207
{
207208
//
208-
$this->authorize('update', $chirp);// [tl! remove:-1,1 add:start]
209+
Gate::authorize('update', $chirp);// [tl! remove:-1,1 add:start]
209210

210211
$validated = $request->validate([
211212
'message' => 'required|string|max:255',

0 commit comments

Comments
 (0)