Protect edit and update functions in EarningController by using policies
MODIFY
app/Http/Controllers/EarningController.php
app/Http/Controllers/EarningController.php
@@ -45,13 +45,13 @@ class EarningController extends Controller {
}
public function edit(Earning $earning) {
- // TODO AUTHORIZE
+ $this->authorize('edit', $earning);
return view('earnings.edit', compact('earning'));
}
public function update(Request $request, Earning $earning) {
- // TODO AUTHORIZE
+ $this->authorize('update', $earning);
// TODO VALIDATE

MODIFY
app/Policies/EarningPolicy.php
app/Policies/EarningPolicy.php
@@ -10,6 +10,14 @@ class EarningPolicy {
return $user->spaces->contains($earning->space_id);
}
+ public function edit(User $user, Earning $earning) {
+ return $user->spaces->contains($earning->space_id);
+ }
+
+ public function update(User $user, Earning $earning) {
+ return $user->spaces->contains($earning->space_id);
+ }
+
public function delete(User $user, Earning $earning) {
return $user->spaces->contains($earning->space_id);
}

Protect edit and update functions in EarningController by using policies