diff --git a/src/Http/Controllers/Api/TransectImageController.php b/src/Http/Controllers/Api/TransectImageController.php index d81be0b..dce2464 100644 --- a/src/Http/Controllers/Api/TransectImageController.php +++ b/src/Http/Controllers/Api/TransectImageController.php @@ -27,7 +27,7 @@ class TransectImageController extends Controller */ public function indexOrderByFilename($id) { $transect = Transect::findOrFail($id); - $this->requireCanSee($transect); + $this->authorize('access', $transect); return $transect->images() ->orderBy('filename', 'asc') diff --git a/src/Http/Controllers/ImageController.php b/src/Http/Controllers/ImageController.php index d7e9621..ea001b0 100644 --- a/src/Http/Controllers/ImageController.php +++ b/src/Http/Controllers/ImageController.php @@ -16,7 +16,7 @@ class ImageController extends Controller public function index($id) { $image = Image::findOrFail($id); - $this->requireCanSee($image); + $this->authorize('access', $image); $exifKeys = ['DateTime', 'Model', 'ShutterSpeedValue', 'ApertureValue', 'Flash', 'GPS Latitude', 'GPS Longitude', 'GPS Altitude']; $image->setAttribute('exif', $image->getExif()); $size = $image->getSize(); diff --git a/src/Http/Controllers/TransectController.php b/src/Http/Controllers/TransectController.php index 9a00da7..d0ca347 100644 --- a/src/Http/Controllers/TransectController.php +++ b/src/Http/Controllers/TransectController.php @@ -17,7 +17,7 @@ class TransectController extends Controller public function create() { $project = Project::findOrFail($this->request->input('project')); - $this->requireCanAdmin($project); + $this->authorize('update', $project); return view('transects::create') ->with('project', $project) @@ -34,12 +34,11 @@ public function create() public function index($id) { $transect = Transect::with('projects')->findOrFail($id); - $this->requireCanSee($transect); + $this->authorize('access', $transect); return view('transects::index') ->with('imageIds', $transect->images()->orderBy('filename', 'asc')->pluck('id')) - ->withTransect($transect) - ->with('isAdmin', $this->user->canAdminOneOfProjects($transect->projectIds())); + ->withTransect($transect); } /** @@ -52,7 +51,7 @@ public function index($id) public function edit($id) { $transect = Transect::with('projects')->findOrFail($id); - $this->requireCanAdmin($transect); + $this->authorize('update', $transect); return view('transects::edit') ->withTransect($transect) diff --git a/src/resources/views/index/menubar.blade.php b/src/resources/views/index/menubar.blade.php index ff2d1da..78a7c66 100644 --- a/src/resources/views/index/menubar.blade.php +++ b/src/resources/views/index/menubar.blade.php @@ -1,7 +1,7 @@
- @if ($isAdmin) + @can ('update', $transect) - @endif + @endcan @if (!empty($modules->getMixins('transectsFilters')))